summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2019-04-30 11:40:13 (GMT)
committerKevin Walzer <kw@codebykevin.com>2019-04-30 11:40:13 (GMT)
commit22119027ff83c020947fe6d3a875bfb29d61ded7 (patch)
treeebe929d4187f3895cca5ae2af72be85db4ffd931 /library
parenta8c34c498bbbe9857df1594751173a188287241c (diff)
downloadtk-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')
-rw-r--r--library/entry.tcl23
-rw-r--r--library/text.tcl20
-rw-r--r--library/ttk/entry.tcl30
3 files changed, 23 insertions, 50 deletions
diff --git a/library/entry.tcl b/library/entry.tcl
index 286b38f..0cc9ffb 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -74,10 +74,12 @@ bind Entry <<TraverseIn>> {
# Standard Motif bindings:
-bind Entry <1> {
+bind Entry <Map> {
if {[tk windowingsystem] eq "aqua"} {
- tk::RegisterServiceWidget %W
+ ::tk::RegisterServiceWidget %W
}
+}
+bind Entry <1> {
tk::EntryButton1 %W %x
%W selection clear
}
@@ -116,9 +118,6 @@ bind Entry <B1-Enter> {
}
bind Entry <ButtonRelease-1> {
tk::CancelRepeat
- if {[tk windowingsystem] eq "aqua"} {
- catch {::tk::CheckEntrySelection %W}
- }
}
bind Entry <Control-1> {
%W icursor @%x
@@ -659,20 +658,6 @@ proc ::tk::EntryGetSelection {w} {
return $entryString
}
-# ::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 933f39b..a03faec 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -38,15 +38,20 @@
# The code below creates the default class bindings for text widgets.
#-------------------------------------------------------------------------
+
+
# Standard Motif bindings:
-bind Text <1> {
- tk::TextButton1 %W %x %y
- %W tag remove sel 0.0 end
+bind Text <Map> {
if {[tk windowingsystem] eq "aqua"} {
::tk::RegisterServiceWidget %W
}
}
+
+bind Text <1> {
+ tk::TextButton1 %W %x %y
+ %W tag remove sel 0.0 end
+}
bind Text <B1-Motion> {
set tk::Priv(x) %x
set tk::Priv(y) %y
@@ -85,10 +90,8 @@ bind Text <B1-Enter> {
}
bind Text <ButtonRelease-1> {
tk::CancelRepeat
- if {[tk windowingsystem] eq "aqua"} {
- clipboard clear
- catch { set selected [%W get sel.first sel.last]}
- catch {clipboard append $selected}
+ if {[tk windowingsystem] eq "aqua"} {
+ ::tk::RegisterServiceWidget %W
}
}
@@ -1212,5 +1215,6 @@ proc ::tk::TextScanDrag {w x y} {
}
if {[info exists Priv(mouseMoved)] && $Priv(mouseMoved)} {
$w scan dragto $x $y
- }
+ }
}
+
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*