Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/TextArea Background Color
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/TextArea Background Color
This example is the version from Mon, 28th Jul 2013.
Project "TextArea Background Color.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
EventHandler Sub Open() dim s as string = me.Text dim rng as new NSRangeMBS( 1,2 ) dim ts as NSTextStorageMBS = me.NSTextViewMBS.textStorage ts.addAttribute( ts.NSBackgroundColorAttributeName, NSColorMBS.redColor, rng ) End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim ta as TextArea = TextArea1 dim ts as NSTextStorageMBS = ta.NSTextViewMBS.textStorage dim s as string = ta.Text dim rng as new NSRangeMBS( 0, s.Len ) dim att as Dictionary = ta.NSTextViewMBS.typingAttributes ts.removeAttribute( ts.NSBackgroundColorAttributeName, rng ) att.Value( "NSBackgroundColor" ) = NSColorMBS.textBackgroundColor ta.NSTextViewMBS.typingAttributes = att End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacControls Plugin.

MBS Xojo Chart Plugins