Bwidget Source Code
Check-in [eb025fca9d]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

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

Overview
Comment:Allow new modifiers Shift, Cmd and ShiftCmd for accelerators [Patch-83ce3e84e7]
Timelines: family | ancestors | descendants | both | patch-83ce3e84e7
Files: files | file ages | folders
SHA1: eb025fca9d272e7361a67cb450b0926ba8f3f687
User & Date: oehhar 2013-06-21 17:00:00
Context
2013-06-26
07:17
Commiting patch [d58b61392d] from ticket [83ce3e84e7] check-in: bb507704b1 user: oehhar tags: bwidget
2013-06-21
17:00
Allow new modifiers Shift, Cmd and ShiftCmd for accelerators [Patch-83ce3e84e7] Closed-Leaf check-in: eb025fca9d user: oehhar tags: patch-83ce3e84e7
16:27
Removed not existing reference generate-widget-doc from pckIndex.tcl [Bug d76eb15928] check-in: a85038b0ba user: oehhar tags: bwidget
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to BWman/MainFrame.html.

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<LI><I>tags</I> is the tags list for the entry, used for enabling or disabling menu
entries with <B>MainFrame::setmenustate</B>.</LI>
<LI><I>menuId</I> is an id for the menu, from which you can get menu pathname with
 <B>MainFrame::getmenu</B>.</LI>
<LI><I>tearoff</I> specifies if menu has tearoff entry.</LI>
<LI><I>description</I> specifies a string for <A HREF=\"DynamicHelp.html\">DynamicHelp</A>.</LI>
<LI><I>accelerator</I> specifies a key sequence. It is a list of two elements, where the first
is one of <B>Ctrl</B>, <B>Alt</B> or <B>CtrlAlt</B>, and the second as letter
(see <A HREF="#-casesensitive">-casesensitive</A> option for interpretation),  digit or
a special key name.
An accelerator string is build and corresponding binding set on the toplevel to invoke the
menu entry.</LI>
<LI><I>option value</I> specifies additionnal options for the entry (see <B>menu add</B>
command).</LI>
</UL>






|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<LI><I>tags</I> is the tags list for the entry, used for enabling or disabling menu
entries with <B>MainFrame::setmenustate</B>.</LI>
<LI><I>menuId</I> is an id for the menu, from which you can get menu pathname with
 <B>MainFrame::getmenu</B>.</LI>
<LI><I>tearoff</I> specifies if menu has tearoff entry.</LI>
<LI><I>description</I> specifies a string for <A HREF=\"DynamicHelp.html\">DynamicHelp</A>.</LI>
<LI><I>accelerator</I> specifies a key sequence. It is a list of two elements, where the first
is one of <B>Shift</B>, <B>Ctrl</B>, <B>Alt</B>, <B>CtrlAlt</B>, <B>Cmd</B>,  or <B>ShiftCmd</B>, and the second as letter
(see <A HREF="#-casesensitive">-casesensitive</A> option for interpretation),  digit or
a special key name.
An accelerator string is build and corresponding binding set on the toplevel to invoke the
menu entry.</LI>
<LI><I>option value</I> specifies additionnal options for the entry (see <B>menu add</B>
command).</LI>
</UL>

Changes to ChangeLog.

2
3
4
5
6
7
8



9
10
11
12
13
14
15
	* labelentry.tcl: Bug fixed:
	Methods from Tk entry widget restored [Bug 1002844].
	
	* mainframe.tcl: Allow case sensitive accelerators
	by new option -casesensitive.
	Patch by cmard [Patch 1977644]



	
2013-01-09 Harald Oehlmann <[email protected]>

	* widget.tcl: Bug fixed:
	Error 'invalid command name ".#BWidget.#ttk::entry"'
	arises in themed mode when an Entry widget should get
	focus by the tab key.






>
>
>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	* labelentry.tcl: Bug fixed:
	Methods from Tk entry widget restored [Bug 1002844].
	
	* mainframe.tcl: Allow case sensitive accelerators
	by new option -casesensitive.
	Patch by cmard [Patch 1977644]
	
	* mainframe.tcl: Allow new modifiers Shift, Cmd and ShiftCmd
	for accelerators. Patch by K.J.Nash [Patch-83ce3e84e7]
	
2013-01-09 Harald Oehlmann <[email protected]>

	* widget.tcl: Bug fixed:
	Error 'invalid command name ".#BWidget.#ttk::entry"'
	arises in themed mode when an Entry widget should get
	focus by the tab key.

Changes to mainframe.tcl.

666
667
668
669
670
671
672
673

674
675
676
677
678
679
680

681
682
683
684
685
686

687
688
689
690
691
692
693

694
695
696
697






698
699
700
701
702
703
704
705
706
707
708
709





















710
711
712
713
714
715
716
717
#	Given a key combo description, construct an appropriate human readable
#	string (for display on as a menu accelerator) and the corresponding
#	bind event.
#
# Arguments:
#	desc		a list with the following format:
#				?sequence? key
#			sequence may be None, Ctrl, Alt, or CtrlAlt

#			key may be any key
#	casesensitive	Boolean if accelerator is case sensitive
#
# Results:
#	{accel event}	a list containing the accelerator string and the event

proc MainFrame::_parse_accelerator { desc casesensitive} {

    if { [llength $desc] == 1 } {
	set seq None
	set key [lindex $desc 0]
	# If the key is an F key (ie, F1, F2, etc), it has to be capitalized
	if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} {
	    set key [string toupper $key]

	}
    } elseif { [llength $desc] == 2 } {
        set seq [lindex $desc 0]
        set key [lindex $desc 1]
	# If the key is an F key (ie, F1, F2, etc), it has to be capitalized
	if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} {
	    set key [string toupper $key]

	}
    } else {
	return {}
    }






    if {! $casesensitive} {
 	set akey [string toupper $key]
 	set ekey [string tolower $key]
    } else {
	set akey $key
	set ekey $key
    }
    switch -- $seq {
	None {
	    set accel $akey
	    set event "<Key-$ekey>"
	}





















	Ctrl {
	    set accel "Ctrl+$akey"
	    set event "<Control-Key-$ekey>"
	}
	Alt {
	    set accel "Alt+$akey"
	    set event "<Alt-Key-$ekey>"
	}






|
>







>






>







>




>
>
>
>
>
>












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
#	Given a key combo description, construct an appropriate human readable
#	string (for display on as a menu accelerator) and the corresponding
#	bind event.
#
# Arguments:
#	desc		a list with the following format:
#				?sequence? key
#			sequence may be None, Ctrl, Alt, CtrlAlt, Shift, Cmd or
#			ShiftCmd
#			key may be any key
#	casesensitive	Boolean if accelerator is case sensitive
#
# Results:
#	{accel event}	a list containing the accelerator string and the event

proc MainFrame::_parse_accelerator { desc casesensitive} {
    set fKey 0
    if { [llength $desc] == 1 } {
	set seq None
	set key [lindex $desc 0]
	# If the key is an F key (ie, F1, F2, etc), it has to be capitalized
	if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} {
	    set key [string toupper $key]
	    set fKey 1
	}
    } elseif { [llength $desc] == 2 } {
        set seq [lindex $desc 0]
        set key [lindex $desc 1]
	# If the key is an F key (ie, F1, F2, etc), it has to be capitalized
	if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} {
	    set key [string toupper $key]
	    set fKey 1
	}
    } else {
	return {}
    }

    # Plain "Shift" can be used only with F keys, but "ShiftCmd" is allowed.
    if {$seq eq "Shift" && (!$fkey)} {
        return -code error {Shift accelerator can be used only with F keys}
    }

    if {! $casesensitive} {
 	set akey [string toupper $key]
 	set ekey [string tolower $key]
    } else {
	set akey $key
	set ekey $key
    }
    switch -- $seq {
	None {
	    set accel $akey
	    set event "<Key-$ekey>"
	}
	Shift {
	# Used only with Function keys.
	    set accel "Shift+$akey"
	    set event "<Shift-Key-$ekey>"
	}
	Cmd {
	    set accel "Cmd+$akey"
	    set event "<Command-Key-$ekey>"
	}
	ShiftCmd {
	    if {    ([tk windowingsystem] eq "aqua")
		 && ([string first AppKit [winfo server .]] == -1)
	    } {
		# Carbon
		set accel "Shift+Cmd+$akey"
		set event "<Shift-Command-Key-$akey>"
	    } else {
		# Cocoa and anything else that uses Cmd
		set accel "Shift+Cmd+$akey"
		set event "<Shift-Command-Key-$ekey>"
	    }
	}	Ctrl {
	    set accel "Ctrl+$akey"
	    set event "<Control-Key-$ekey>"
	}
	Alt {
	    set accel "Alt+$akey"
	    set event "<Alt-Key-$ekey>"
	}