From 659f7071997ade9b977ca0a28e57b1f947208f3b Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 7 Mar 2018 03:51:46 +0000 Subject: Implement script level bindings --- library/entry.tcl | 20 ++++++++++++++++++++ library/text.tcl | 6 ++++++ library/ttk/entry.tcl | 20 ++++++++++++++++++++ macosx/Wish-Info.plist.in | 21 +++++++++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/library/entry.tcl b/library/entry.tcl index 6243d26..780fcb2 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -113,6 +113,9 @@ bind Entry { } bind Entry { tk::CancelRepeat + if {[tk windowingsystem] eq "aqua"} { + ::tk::CheckEntrySelection %W + } } bind Entry { %W icursor @%x @@ -652,3 +655,20 @@ proc ::tk::EntryGetSelection {w} { } return $entryString } + + +if {[tk windowingsystem] eq "aqua"]{ +# ::tk::CheckEntrySelection -- +# +# Writes selected text to the clipboard on macOS. +# +# Arguments: +# w - The entry window from which the text to get + +proc ::tk::CheckEntrySelection {w} { + if {[$w selection present]} { + clipboard clear + clipboard append [::tk::EntryGetSelection $w] + } +} +} diff --git a/library/text.tcl b/library/text.tcl index 468696b..c76153c 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -395,6 +395,12 @@ bind Text { tk::TextScrollPages %W 1 } +bind Text <> { + clipboard clear + set selected [%W get sel.first sel.last] + clipboard append $selected +} + # End of Mac only bindings } diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index b3ebcbd..7ac29e4 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -427,6 +427,9 @@ proc ttk::entry::Release {w} { variable State set State(selectMode) none ttk::CancelRepeat ;# suspend autoscroll + if {[tk windowingsystem] eq "aqua"} { + ::ttk::CheckEntrySelection $w + } } ## AutoScroll @@ -604,4 +607,21 @@ 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::EntrySelection $w] + } + } +} + + #*EOF* diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in index d2fc388..0a22527 100644 --- a/macosx/Wish-Info.plist.in +++ b/macosx/Wish-Info.plist.in @@ -78,5 +78,26 @@ Wish.sdef NSHighResolutionCapable True + NSServices + + NSMenuItem + + default + Wish: Run Tcl Script + + NSMessage + provideService + NSPortName + Wish + NSSendTypes + + NSStringPboardType + + NSReturnTypes + + NSStringPboardType + + + -- cgit v0.12