Here are a few things that came up when I was working on PIVOT-637.
Rather than put them straight into JIRA, it might be best to solicit
comments here.
This is a rather long mail, so perhaps replies should just state the 'issue'
number to avoid excessive quoting.
1. (Improvement / New Feature)
org.apache.pivot.wtk.Keyboard has the following method which is used
extensively thoughout the keypress handling code within Pivot
public static boolean isPressed(Modifier modifier) {
return (modifiers & modifier.getMask()) > 0;
}
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java
It returns true if the specified modifier is pressed, regardless of any
other modifiers which might also be pressed.
I think there should be an equivalent method which only return true if all
specified modifiers are pressed
Something like
/**
* Return true if all of the supplied keyboard modifiers are currently
pressed.
*/
public static boolean allPressed(final Modifier... modifiers) {
...
}
and/or
/**
* Return bitfield for all of the supplied keyboard modifiers combined. <br>
* This can then be used for comparisons with the keyboard modifiers that
* are actually pressed at any given moment.
*
* <pre>
* if (getModifiers() == getModifierMask(Modifier.CTRL, Modifier.SHIFT)) {
* if (keyCode == Keyboard.KeyCode.X) {
* // Do something only if Control+Shift+X are pressed
* // Not called if Control+Shift+Alt+X are pressed
* }
* }
* </pre>
*/
public static int getModifierMask(final Modifier... modifiers) {
int mask = 0;
for (final Modifier modifier : modifiers) {
mask |= modifier.getMask();
}
return mask;
}
This will enable more controlled 'capture' of keypresses as can be seen in
the next point
2. (Improvement / New Feature)
org.apache.pivot.wtk.skin.ComponentSkin.keyPressed() handles TAB & SHIFT+TAB
keys to transfer focus between components
It doesn't care whether any or all of ALT, CTRL, META are also pressed.
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
(SHIFT+)ALT+TAB is commonly used in MS Windows to switch between running
applications (Task Switcher)
http://en.wikipedia.org/wiki/Alt-Tab
and (SHIFT+)CTRL+TAB is often used to navigate between tabs
http://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts#Tab_management
We could add simple check to ensure that the focus traversal code is not
executed if CTRL/META or ALT are pressed.
(see above)
The same would apply to virtually all keyboard handling.
If a component really doesn't care about modifiers, then it should be
clearly stated in the javadocs.
3. (Improvement / New Feature)
XXX.keyTyped() methods which select the next item matching the keypress
should probably
- Move in the opposite direction when SHIFT is pressed
- Loop around so that it would be possible to loop through all matching
items if you press the key enough times
http://svn.apache.org/repos/asf/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
4. (Improvement / New Feature)
Pressing SPACE in TerraListViewSkin & TerraTreeViewSkin will toggle check
mark state only when selection mode is SelectMode.SINGLE
Why not process all selected items, and therefore work SelectMode.MULTI?
This could either just invert each individual item, or set them all to a
common state before toggling between checked and unchecked.
http://svn.apache.org/repos/asf/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
http://svn.apache.org/repos/asf/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
5. (Bug)
TAB & SHIFT+TAB have no effect in MenuBarItemSkin, but should perform like
LEFT & RIGHT arrows and change the activated menu
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java
This looks to be because ComponentSkin.keyPressed() consumes the TAB
keypresses, so they never reach MenuBarItemSkin
/pivot-trunk/tests/src/org/apache/pivot/tests/menu_bar_test.bxml
/pivot-trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml
6. (Question)
In TerraFileBrowserSkin, the ENTER key only works if
keyboardFolderTraversalEnabled has been set, but
DELETE & BACKSPACE work regardless.
For consistency, should DELETE & BACKSPACE require
keyboardFolderTraversalEnabled to be true if ENTER does?
http://svn.apache.org/repos/asf/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
Regards,
Chris