I have added radio buttons to various forms and even though I can focus on the radio buttons with "tab" I can not choose them pressing "spacebar".
The arrow keys work so I can circle between the two radio buttons I have, but I need the "spacebar" functionality. With normal this works ok, not with though.
Is this some kind of bug or is there a workaround?
Since Primefaces RadioButtons are customized to display the theme oriented RadioButton,the Space Bar wont Work.
If you want the space bar to work you are gonna have to give up the theme oriented style of RadioButton. And use the native style (Browser Default Style) on radiobuttons.
You can do that using plain attribute as follows:
<p:selectOneRadio id="customRadio" plain="true">
Related
I am building my first CodenameOne app using the GUI Builder. I've defined a style for my buttons where the "unselected" state is regular text and the "selected" or focus state has Bold text.
The problem I'm seeing is that once a button gains focus, the bold text is slightly wider than the original text and it starts scrolling (I think the effect is referred to as "tickering"):
Unselected Button Image
Selected Button Image
I see this in the simulator and on my Samsung SG6 testing. Is this a bug or is there something I can do to pre-size it for the bold text first so it doesn't start scrolling when it gets focus? I don't want to make the button larger than it needs to be (ie: fit it to a container)
You need to do 2 things,
first reduce the left and right padding of the selected button UIID and then call this in your code
mybutton.setEndsWith3Points(false);
mybutton.setTickerEnabled(false);
As an extra, place the button in a container with the right layout.
Note that since the text is now Bold, it's normal for the button to gain extra width. So I will suggest you make a room for that.
Edit:
I noticed that the button was tickering when you took the snapshot so ignore the first point about padding.
I've started to learn Javafx and I happened upon this "strange" feature. I've made a simple window with two buttons. When I press one of them a blue stroke appears and stays there until I press the other button. I can't find any logical use of this other than knowing which button was pressed last. Even from a UX perspective, it doesn't make sense. I've tried somehow to "deactivate" it throught CSS but no luck. Is there any solution for this?
It's hard to tell what you are searching for without the code.
But I think you are referring to the visual marker for the currently focused menu item. This function is used in situations where the user hit's the "Tab"-Key to navigate through your menu items.
You can disable this feature for items by unchecking the "Focus Traversable" option in the "Properties" Tab. This will also disable the tab navigation!
There is already a thread that has a solution for exactly this topic. See:Remove Focus Box Around TextField
It talks about disabling the focus color using css, while keeping the tab navigation feature by using this css styling rule:
-fx-focus-color: transparent;
(Source: Uluk Biy's answer in the linked topic)
The blue outline around controls in JavaFX is there to indicate which control has focus.
Focus indicators are a common idiom used across different UI frameworks, not specific to just JavaFX. In a traditional mouse/keyboard based input setup, there needs to be some indication of where a keystroke will be sent when a key is pressed. Imagine there are multiple fields on a form, a few text fields and a couple of buttons. If the user types some characters - how does the system know into which text field to insert the characters? Similarly if the user presses return to activate a button, which button will get activated? The answer is that the button or field which currently has focus will receive the input. The focus can be changed usually by pressing the tab key to tab to a new field or pressing on a different field with the mouse. However, even though the system knows that which field has focus, it is important to provide feedback to the user to let the user know which field has focus. That way when the user types, they have some idea of where there input will be directed.
What you see with a blue outline around a button in JavaFX is a visual indicator to note that the button has focus and, if you press space, that button's action will be triggered and not some other button. When you click the mouse on another button it will both trigger the other button's action and transfer focus to that button, so if you subsequently press space, the last clicked button will be actioned again.
The focus color for a controls in JavaFX that are using the default modena.css stylesheet which comes with JavaFX 8, can be controlled by a couple of css properties which you can override in the user stylesheet for your application (by defining the properties in the .root {} css style class:
/* A bright blue for the focus indicator of objects. Typically used as the
* first color in -fx-background-color for the "focused" pseudo-class. Also
* typically used with insets of -1.4 to provide a glowing effect.
*/
-fx-focus-color: #039ED3;
-fx-faint-focus-color: #039ED322;
So, for instance, you could remove all focus colors from your application using:
.root {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
However, removing focus color indicators would probably make your application much less intuitive and more difficult to understand.
Let's look at a simple form in JavaFX:
The blue ring around the text input field for User Name indicates that text input will go into that field.
Is there a proper way to disable the focus ring only from my project's buttons?
If you want to disable focus feedback only for buttons and for all buttons in a project and also not effect other controls, then you can define a stylesheet rule for that:
.button {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
Note: I still don't recommend doing this even if other frameworks you use do not provide focus rings for buttons.
This will override the default focus coloring for buttons defined in the default JavaFX 8 modena.css stylesheet. You do not need to (nor should you) modify the modena.css stylesheet to override values in it. You can just redefine the values using a more specific CSS selector rule within your application's stylesheet. If you need to understand how CSS selectors work, there are numerous resources on the web you can search for and read. Oracle provide a getting started tutorial on how you can set a custom CSS style for a scene. The relevant code line is to add your user stylesheet to your scene:
scene.getStylesheets().add(
MyApplication.class.getResource(
"my-stylesheet.css"
).toExternalForm()
);
Google Chrome Recently had an update that added an extra button onto to the top of the window that allowed you edit your account settings. I have a great use for an extra button like this one but I do not know how to make it. So, how can I add an extra button at the top of the window?
This is what I would like to do or have in mind.
This is more of an amateur/simple answer but it could be possible just to make a title bar with all of the drop downs without text until you reach the button you want and customize that
I'd like to create a set of buttons in a Java Swing application like you get in a typical tool palette in a paint program. That is, a set of small square buttons, each containing an icon, only one of which is pressed down, and when you press another button, the first is deselected. I've thought of a number of solutions and none of them seem very easy/elegant.
This sounds like a job for JRadioButton, but if you add an Icon to that, you still get the small circle, which is fairly space inefficient. I guess an option would be finding an alternative Look and Feel or painting code for JRadioButton.
Another alternative might be to add JButton to a ButtonGroup, maybe setting a JToggleButton.ToggleButtonModel as the model, but that doesn't have the desired effect, as the painting code for a standard JButton does not keep it depressed when selected. Possibly the JButton code could be modified to do this. Like making it painting "selected" the same way as "pressed".
A third alternative would be to use normal JButton's, and add a common mouse listener that keeps them pressed or not, and communicates the changes between the buttons.
Can anyone advise on the best way to achieve the aim please? A simple method I've missed would be best, but advice on which of these three alternatives would be best and pointers on how to get started would be useful too.
What about a plain JToggleButton in a ButtonGroup? It is not abstract, you can instantiate one with an Icon, and it stays depressed while selected.
See the SwingSet2 demo:
http://java.sun.com/products/plugin/1.4/demos/jfc/SwingSet2/SwingSet2.html
Click the second icon on the toolbar (the one twith the check box and radio button) then tab "Radio buttons". Then click on "Paint Border" on the right panel, under "Display Options".
Source code of the demo is under your JDK install dir, so for example on my PC it's under \jdk1.6.0_01\demo\jfc\SwingSet2\src
I'm developing a SWT app and in one particular form there are 14 pairs of Yes-No radio buttons. Each of these pairs have a text box associated with them. So if a user selects Yes, the associated textbox should be editable else uneditable. I find writing 28 listeners for the radio buttons really daunting. Since the radio buttons have nothing much to do than just rendering the textbox editable/uneditable I was hoping if there were some generic type of listeners in SWT that would be applicable to a set of radio buttons specified in an array or like that. Are there any frameworks or shall I have to write individual listeners?
Edit
I'm trying to fire an event only when the radio button is selected
rdoExperience.addListener(SWT.CHECK, new RadioButtonSelection(
txtExperience));
but SWT.CHECK is causing the event to be fired on mouse hover over radio button too. I've tried using SWT.SELECTED too but it's not working either and I can't find other suitable SWT constants. W;hat should I use?
Good point. Sorry I don't know such thing.
However, you create one yourself: Instead of writing an anonymous listener for every button, you could write one - say MyButtonListener - and give it the button text box as an argument. Than you instantiate MyButtonListener with the appropriate text box as an argument. Than in the Listeners appropriate callback method you enable or disable the text box.
Edit: My bad. Of course I meant you could give it your text box like radioBtn.addListener(SWT.SELECTED, new MyButtonListener(textfield1));
You could create one SelectionListener and add it to each of the radio buttons. Then you can ascertain which button was pressed from the selection event and map that to a text box. For the mapping you could use an array or hashtable.