[Review request] 8178519: Consider removing two-level focus support from UI controls
Kevin, Phil, Could you please review the webrev below, which aims to remove the unused two-level focus code that presently ships in JDK 9 and earlier releases. https://bugs.openjdk.java.net/browse/JDK-8178519 http://cr.openjdk.java.net/~jgiles/8178519/ Thanks, -- -- Jonathan
Re: Two Level Focus
On 18/11/2013 14:25, mick.fleming wrote: However, if you do click on it with the mouse (by selecting one of its items), focus is stuck there and cannot be moved anymore with just the 5 buttons. when you click on a two_level control with a mouse it goes straight into 'internal mode', as at this stage it's obvious that there are mouse events. Yes, I looked at the code, and it is no big deal. I've mapped the OK button on my remote to ENTER as well. Unfortunately, I have some problems using the "-Dcom.sun.javafx.twoLevelFocus=true" mode directly, so I'm simulating it now by skinning the controls that need it to support two level focus. ComboBox for example, I just block certain keys (as was done in TwoLevelFocusComboBehavior) when "isShowing" is true/false. I also skinned Button and CheckBox to accept ENTER instead of SPACE to toggle/select them. One of the problems encountered is that I cannot focus say a ListView directly to "interal focus", so whenever I have a window that only shows a ListView, the user has to press ENTER or OK first to get it to work, which is a bit counter-intuitive -- so that might be future enhancement that could be useful. One thing I was wondering though, it is 5 key navigation, but I actually use 6 keys (left, right, up, down, select and back). Especially the back key is very useful for escaping contexts without selecting anything (like a ComboBox can be escaped without changing the selection). Not sure if such a key could be supported as well. Anyway, my app is for personal use only, so I don't mind testing this kind of thing out and playing around with it -- I'll work around any problems I encounter, and I don't mind if it stops working or is changed in the future. BTW not all controls were selected to have two level functionality, and not all style sheets have separate internal-focus styles. I only use a very limited subset of controls so far (The View controls, Button, CheckBox and ComboBox). If I encounter problems, I'm getting familair enough with the Behavior classes and their workings to change behavior where needed :) --John
Re: Two Level Focus
Hi John, However, if you do click on it with the mouse (by selecting one of its items), focus is stuck there and cannot be moved anymore with just the 5 buttons. when you click on a two_level control with a mouse it goes straight into 'internal mode', as at this stage it's obvious that there are mouse events. If you go back to 'external mode' normal traversal should be available again. On desktops the OK function is mapped to Enter, so just pressing Enter should work. You can enable this from the command line with : -Dcom.sun.javafx.twoLevelFocus=true BTW not all controls were selected to have two level functionality, and not all style sheets have separate internal-focus styles. regards, mick
Re: Two Level Focus
Hi John, TWO_LEVEL_FOCUS is a feature developed for embedded platforms. However it can be enabled for desktop platforms by setting a system property in the way you describe. The kind of input device you have is exactly a match for two level focus. On embedded platforms the criterion for setting two level focus is that arrow and select keys are available but not a full PC keyboard. Unfortunately there are a number of bugs currently filed against two level focus and we are not going to be fixing all of them for the upcoming Java 8 release. I do encourage you to file JIRAs on specific issues you run into so that we can track them in update releases. If you can include sample code and information on what JavaFX key codes are generated by your remote, that will help. Thanks, Daniel Yes, you can enable TWO_LEVEL_FOCUS on non-embedded platforms On Nov 16, 2013, at 5:22 PM, John Hendrikx wrote: > Hi list, > > I'm wondering how well the Conditional Feature "TWO_LEVEL_FOCUS" works, and > if it is allowed to be used on non-embedded platforms. > > My main JavaFX project is basically a Windows/Linux application that runs > without focus and is controlled with a remote control (no mouse or keyboard, > although keyboard events are synthesized). This means I often run into > problems related to the Window not having focus (controls donot show it, > combobox drop downs close automatically, etc.) > > While fixing yet another of these problems in custom controls / skins, I ran > into the Conditional Feature above, which quite accurately describes what I'm > doing (remote control only has left/right/up/down and an OK button... and a > back button) which qualifies as two level navigation I think. So I tried > turning this on on Windows using: > >System.setProperty("com.sun.javafx.twoLevelFocus", "true"); > > ...which I dug up out of Jira. This changes ComoBox control atleast to not > respond to "up" and "down" keys when it has the focus, allowing me to move > away from it. However, if you do click on it with the mouse (by selecting > one of its items), focus is stuck there and cannot be moved anymore with just > the 5 buttons. > > Anyway, this sounds like it is exactly what I need and may save me a lot of > work, any more information about it is appreciated! > > --John > > >
Two Level Focus
Hi list, I'm wondering how well the Conditional Feature "TWO_LEVEL_FOCUS" works, and if it is allowed to be used on non-embedded platforms. My main JavaFX project is basically a Windows/Linux application that runs without focus and is controlled with a remote control (no mouse or keyboard, although keyboard events are synthesized). This means I often run into problems related to the Window not having focus (controls donot show it, combobox drop downs close automatically, etc.) While fixing yet another of these problems in custom controls / skins, I ran into the Conditional Feature above, which quite accurately describes what I'm doing (remote control only has left/right/up/down and an OK button... and a back button) which qualifies as two level navigation I think. So I tried turning this on on Windows using: System.setProperty("com.sun.javafx.twoLevelFocus", "true"); ...which I dug up out of Jira. This changes ComoBox control atleast to not respond to "up" and "down" keys when it has the focus, allowing me to move away from it. However, if you do click on it with the mouse (by selecting one of its items), focus is stuck there and cannot be moved anymore with just the 5 buttons. Anyway, this sounds like it is exactly what I need and may save me a lot of work, any more information about it is appreciated! --John