diff options
author | Kevin Walzer <kw@codebykevin.com> | 2019-04-30 11:40:13 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2019-04-30 11:40:13 (GMT) |
commit | 22119027ff83c020947fe6d3a875bfb29d61ded7 (patch) | |
tree | ebe929d4187f3895cca5ae2af72be85db4ffd931 /library/ttk | |
parent | a8c34c498bbbe9857df1594751173a188287241c (diff) | |
download | tk-22119027ff83c020947fe6d3a875bfb29d61ded7.zip tk-22119027ff83c020947fe6d3a875bfb29d61ded7.tar.gz tk-22119027ff83c020947fe6d3a875bfb29d61ded7.tar.bz2 |
Automatically bind text, entry, ttk::entry widgets to Services API at widget creation/mapping; re-work data mechanism to use selection rather than clipboard API, thanks to Marc Culler for that insight
Diffstat (limited to 'library/ttk')
-rw-r--r-- | library/ttk/entry.tcl | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 6d5be07..50f866d 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -58,6 +58,13 @@ option add *TEntry.cursor [ttk::cursor text] widgetDefault # and I'll put it back. # +##Bindings to register with macOS Services API. +bind T.Entry <Map> { + if {[tk windowingsystem] eq "aqua"} { + ::tk::RegisterServiceWidget %W + } +} + ## Clipboard events: # bind TEntry <<Cut>> { ttk::entry::Cut %W } @@ -348,9 +355,6 @@ proc ttk::entry::Press {w x} { set State(x) $x set State(selectMode) char set State(anchor) [$w index insert] - if {[tk windowingsystem] eq "aqua"} { - ::tk::RegisterServiceWidget $w - } } ## Shift-Press -- Shift-ButtonPress-1 binding. @@ -430,9 +434,6 @@ proc ttk::entry::Release {w} { variable State set State(selectMode) none ttk::CancelRepeat ;# suspend autoscroll - if {[tk windowingsystem] eq "aqua"} { - catch {::ttk::CheckEntrySelection $w} - } } ## AutoScroll @@ -610,21 +611,4 @@ proc ttk::entry::Delete {w} { } } -if {[tk windowingsystem] eq "aqua"} { - # ::ttk::CheckEntrySelection -- - # - # Writes selected text to the clipboard on macOS. - # - # Arguments: - # w - The entry window from which the text to get - - proc ::ttk::CheckEntrySelection {w} { - if {[$w selection present]} { - clipboard clear - clipboard append [::ttk::entry::EntrySelection $w] - } - } -} - - #*EOF* |