Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/NSTextView Selection
Function:
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/NSTextView Selection
This example is the version from Sun, 11th Aug 2012.
Project "NSTextView Selection.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim start as UInt32 = val(TextField1.Text) dim length as UInt32 = val(TextField2.Text) TextArea1.myTextView.scrollRangeToVisible( start, length ) dim range as NSRangeMBS range = NSMakeRangeMBS( start, length ) TextArea1.myTextView.showFindIndicatorForRange( range ) End EventHandler
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control TextField2 Inherits TextField
ControlInstance TextField2 Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control TextArea1 Inherits myTextArea
ControlInstance TextArea1 Inherits myTextArea
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim start as UInt32 = val(TextField1.Text) dim length as UInt32 = val(TextField2.Text) TextArea1.myTextView.scrollRangeToVisible( start, length ) dim range as NSRangeMBS range = NSMakeRangeMBS( start, length ) TextArea1.myTextView.selectedRange = range End EventHandler
End Control
EventHandler Sub Close() Quit() End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditRedo = "Redo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class myTextArea Inherits TextArea
Event Open() End Event
EventHandler Sub Open() myTextView = me.NSTextViewMBS ' work around a bug (input Japanese) myTextView.isFieldEditor=false ' Noncontiguous Layout myTextView.layoutManager.allowsNonContiguousLayout = true ' margin myTextView.textContainerInset = NSMakeSizeMBS(2,7) ' Plain text myTextView.isRichText = false ' Font myTextView.font = NSFontMBS.fontWithName("LucidaGrande", 14.0) ' other setting myTextView.usesFontPanel = true myTextView.smartInsertDeleteEnabled = false myTextView.AutomaticQuoteSubstitutionEnabled = false myTextView.ContinuousSpellCheckingEnabled=false myTextView.GrammarCheckingEnabled = false myTextView.AutomaticLinkDetectionEnabled = false myTextView.allowsImageEditing = false myTextView.acceptsGlyphInfo = false if IsSnowLeopardAfter then myTextView.AutomaticDashSubstitutionEnabled = false myTextView.AutomaticTextReplacementEnabled = false myTextView.AutomaticSpellingCorrectionEnabled = false myTextView.AutomaticDataDetectionEnabled = false end if Open() End EventHandler
EventHandler Sub TextChange() ' work around a bug (Rb TextArea) myTextView.font = NSFontMBS.fontWithName("LucidaGrande", 14.0) End EventHandler
Function IsSnowLeopardAfter() As Boolean Dim SystemVersion as Integer Call System.Gestalt("sysv", SystemVersion) Return (SystemVersion >= &h1060) End Function
Property myTextView As NSTextViewMBS
End Class
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS Xojo Chart Plugins