Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/NSTextView Selection


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 Fri, 3rd Mar 2022.

Project "NSTextView Selection.xojo_binary_project"
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 myTextView.AutomaticDashSubstitutionEnabled = false myTextView.AutomaticTextReplacementEnabled = false myTextView.AutomaticSpellingCorrectionEnabled = false myTextView.AutomaticDataDetectionEnabled = false Open() End EventHandler
EventHandler Sub TextChange() ' work around a bug (Rb TextArea) myTextView.font = NSFontMBS.fontWithName("LucidaGrande", 14.0) End EventHandler
Property myTextView As NSTextViewMBS
End Class
End Project

See also:

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


The biggest plugin in space...