Tk Source Code

Check-in [6e2fb2dd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[Bug 3555644]: Better use of virtual events, Add <<ToggleSelection>> virtual event.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6e2fb2ddce13127a95c2f5dc485d6afa5d1f8811
User & Date: jan.nijtmans 2012-08-23 10:50:31
Context
2012-08-23
21:42
3554026,3561016 Stop crash with tearoff menus check-in: 2eee9b6a user: dgp tags: trunk
10:50
[Bug 3555644]: Better use of virtual events, Add <<ToggleSelection>> virtual event. check-in: 6e2fb2dd user: jan.nijtmans tags: trunk
07:06
new virtual event <<ToggleSelection>> Closed-Leaf check-in: 1b0ecb59 user: jan.nijtmans tags: bug-3555644
2012-08-22
23:23
And *this* time with the right TIP number. :-} check-in: d249166d user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.







1
2
3
4
5
6
7






2012-08-22  Jan Nijtmans  <[email protected]>

	TIP #403 IMPLEMENTATION

	* xlib/xcolors.c:     Web Colors for Tk. New colors aqua, crimson,
	* xlib/rgb.txt:       fuchsia, indigo, lime, olive, silver and teal.
	* unix/tkUnixColor.c: Modified RGB values for gray/grey, green,
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2012-08-23  Jan Nijtmans  <[email protected]>

	* library/tk.tcl:        [Bug 3555644]: Better use of virtual events,
	* library/ttk/entry.tcl  Add <<ToggleSelection>> virtual event.
	* library/ttk/treeview.tcl

2012-08-22  Jan Nijtmans  <[email protected]>

	TIP #403 IMPLEMENTATION

	* xlib/xcolors.c:     Web Colors for Tk. New colors aqua, crimson,
	* xlib/rgb.txt:       fuchsia, indigo, lime, olive, silver and teal.
	* unix/tkUnixColor.c: Modified RGB values for gray/grey, green,

Changes to doc/event.n.

476
477
478
479
480
481
482




483

484
485
486
487
488
489
490
range of selected contents.
.TP
\fB<<SelectPrevWord>>\fR
.
Move to the previous group of items (i.e., visible word) in the current widget
while extending the range of selected contents.
.TP




\fB<<Undo>>\fR

Undo the last action.
.SH EXAMPLES
.SS "MAPPING KEYS TO VIRTUAL EVENTS"
.PP
In order for a virtual event binding to trigger, two things must
happen.  First, the virtual event must be defined with the
\fBevent add\fR command.  Second, a binding must be created for







>
>
>
>

>







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
range of selected contents.
.TP
\fB<<SelectPrevWord>>\fR
.
Move to the previous group of items (i.e., visible word) in the current widget
while extending the range of selected contents.
.TP
\fB<<ToggleSelection>>\fR
.
Toggle the selection.
.TP
\fB<<Undo>>\fR
.
Undo the last action.
.SH EXAMPLES
.SS "MAPPING KEYS TO VIRTUAL EVENTS"
.PP
In order for a virtual event binding to trigger, two things must
happen.  First, the virtual event must be defined with the
\fBevent add\fR command.  Second, a binding must be created for

Changes to library/tk.tcl.

387
388
389
390
391
392
393

394
395
396
397
398
399
400
	event add <<NextLine>>		<Down> <Control-Key-n> <Control-Lock-Key-N>
	event add <<SelectPrevLine>>	<Shift-Up> <Control-Key-P> <Control-Lock-Key-p>
	event add <<SelectNextLine>>	<Shift-Down> <Control-Key-N> <Control-Lock-Key-n>
	event add <<PrevPara>>		<Control-Up>
	event add <<NextPara>>		<Control-Down>
	event add <<SelectPrevPara>>	<Control-Shift-Up>
	event add <<SelectPrevPara>>	<Control-Shift-Down>


	# Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is
	# returned when the user presses <Shift-Tab>. In order for tab
	# traversal to work, we have to add these keysyms to the PrevWindow
	# event. We use catch just in case the keysym isn't recognized.

	# This is needed for XFree86 systems







>







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
	event add <<NextLine>>		<Down> <Control-Key-n> <Control-Lock-Key-N>
	event add <<SelectPrevLine>>	<Shift-Up> <Control-Key-P> <Control-Lock-Key-p>
	event add <<SelectNextLine>>	<Shift-Down> <Control-Key-N> <Control-Lock-Key-n>
	event add <<PrevPara>>		<Control-Up>
	event add <<NextPara>>		<Control-Down>
	event add <<SelectPrevPara>>	<Control-Shift-Up>
	event add <<SelectPrevPara>>	<Control-Shift-Down>
	event add <<ToggleSelection>>	<Control-ButtonPress-1>

	# Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is
	# returned when the user presses <Shift-Tab>. In order for tab
	# traversal to work, we have to add these keysyms to the PrevWindow
	# event. We use catch just in case the keysym isn't recognized.

	# This is needed for XFree86 systems
435
436
437
438
439
440
441

442
443
444
445
446
447
448
	event add <<NextLine>>		<Down>
	event add <<SelectPrevLine>>	<Shift-Up>
	event add <<SelectNextLine>>	<Shift-Down>
	event add <<PrevPara>>		<Control-Up>
	event add <<NextPara>>		<Control-Down>
	event add <<SelectPrevPara>>	<Control-Shift-Up>
	event add <<SelectPrevPara>>	<Control-Shift-Down>

    }
    "aqua" {
	event add <<Cut>>		<Command-Key-x> <Key-F2> <Control-Lock-Key-X>
	event add <<Copy>>		<Command-Key-c> <Key-F3> <Control-Lock-Key-C>
	event add <<Paste>>		<Command-Key-v> <Key-F4> <Control-Lock-Key-V>
	event add <<PasteSelection>>	<ButtonRelease-2>
	event add <<Clear>>		<Clear>







>







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
	event add <<NextLine>>		<Down>
	event add <<SelectPrevLine>>	<Shift-Up>
	event add <<SelectNextLine>>	<Shift-Down>
	event add <<PrevPara>>		<Control-Up>
	event add <<NextPara>>		<Control-Down>
	event add <<SelectPrevPara>>	<Control-Shift-Up>
	event add <<SelectPrevPara>>	<Control-Shift-Down>
	event add <<ToggleSelection>>	<Control-ButtonPress-1>
    }
    "aqua" {
	event add <<Cut>>		<Command-Key-x> <Key-F2> <Control-Lock-Key-X>
	event add <<Copy>>		<Command-Key-c> <Key-F3> <Control-Lock-Key-C>
	event add <<Paste>>		<Command-Key-v> <Key-F4> <Control-Lock-Key-V>
	event add <<PasteSelection>>	<ButtonRelease-2>
	event add <<Clear>>		<Clear>
472
473
474
475
476
477
478

479
480
481
482
483
484
485
	event add <<SelectNextLine>>	<Shift-Down> <Control-Key-N> <Control-Lock-Key-n>
	# Not official, but logical extensions of above. Also derived from
	# bindings present in MS Word on OSX.
	event add <<PrevPara>>		<Option-Up>
	event add <<NextPara>>		<Option-Down>
	event add <<SelectPrevPara>>	<Shift-Option-Up>
	event add <<SelectPrevPara>>	<Shift-Option-Down>

    }
}

# ----------------------------------------------------------------------
# Read in files that define all of the class bindings.
# ----------------------------------------------------------------------








>







474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
	event add <<SelectNextLine>>	<Shift-Down> <Control-Key-N> <Control-Lock-Key-n>
	# Not official, but logical extensions of above. Also derived from
	# bindings present in MS Word on OSX.
	event add <<PrevPara>>		<Option-Up>
	event add <<NextPara>>		<Option-Down>
	event add <<SelectPrevPara>>	<Shift-Option-Up>
	event add <<SelectPrevPara>>	<Shift-Option-Down>
	event add <<ToggleSelection>>	<Command-ButtonPress-1>
    }
}

# ----------------------------------------------------------------------
# Read in files that define all of the class bindings.
# ----------------------------------------------------------------------

Changes to library/ttk/entry.tcl.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
bind TEntry <Triple-ButtonPress-1> 	{ ttk::entry::Select %W %x line }
bind TEntry <B1-Motion>			{ ttk::entry::Drag %W %x }

bind TEntry <B1-Leave> 		{ ttk::Repeatedly ttk::entry::AutoScroll %W }
bind TEntry <B1-Enter>		{ ttk::CancelRepeat }
bind TEntry <ButtonRelease-1>	{ ttk::CancelRepeat }

bind TEntry <Control-ButtonPress-1> {
    %W instate {!readonly !disabled} { %W icursor @%x ; focus %W }
}

## Button2 bindings:
#	Used for scanning and primary transfer.
#	Note: ButtonRelease-2 is mapped to <<PasteSelection>> in tk.tcl.
#







|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
bind TEntry <Triple-ButtonPress-1> 	{ ttk::entry::Select %W %x line }
bind TEntry <B1-Motion>			{ ttk::entry::Drag %W %x }

bind TEntry <B1-Leave> 		{ ttk::Repeatedly ttk::entry::AutoScroll %W }
bind TEntry <B1-Enter>		{ ttk::CancelRepeat }
bind TEntry <ButtonRelease-1>	{ ttk::CancelRepeat }

bind TEntry <<ToggleSelection>> {
    %W instate {!readonly !disabled} { %W icursor @%x ; focus %W }
}

## Button2 bindings:
#	Used for scanning and primary transfer.
#	Note: ButtonRelease-2 is mapped to <<PasteSelection>> in tk.tcl.
#

Changes to library/ttk/treeview.tcl.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
bind Treeview	<KeyPress-Prior>	{ %W yview scroll -1 pages }
bind Treeview	<KeyPress-Next> 	{ %W yview scroll  1 pages }
bind Treeview	<KeyPress-Return>	{ ttk::treeview::ToggleFocus %W }
bind Treeview	<KeyPress-space>	{ ttk::treeview::ToggleFocus %W }

bind Treeview	<Shift-ButtonPress-1> \
		{ ttk::treeview::Select %W %x %y extend }
bind Treeview	<Control-ButtonPress-1> \
		{ ttk::treeview::Select %W %x %y toggle }

ttk::copyBindings TtkScrollable Treeview 

### Binding procedures.
#








|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
bind Treeview	<KeyPress-Prior>	{ %W yview scroll -1 pages }
bind Treeview	<KeyPress-Next> 	{ %W yview scroll  1 pages }
bind Treeview	<KeyPress-Return>	{ ttk::treeview::ToggleFocus %W }
bind Treeview	<KeyPress-space>	{ ttk::treeview::ToggleFocus %W }

bind Treeview	<Shift-ButtonPress-1> \
		{ ttk::treeview::Select %W %x %y extend }
bind Treeview	<<ToggleSelection>> \
		{ ttk::treeview::Select %W %x %y toggle }

ttk::copyBindings TtkScrollable Treeview 

### Binding procedures.
#