Reputation: 31
In my application I have a multi step form wizard in which the next button is disabled unless all the required fields are entered.
Some fields require extra validation such as the directory picker, for which I have to check whether the directory exists or not.
To ease the user experience I need to show an "Invalid directory" tooltip next to the directory text field.
I would like to show the tooltips when the user tries to click/enter the disabled next button.
Is it possible to capture events performed on a disabled button in JavaFX?
public void nextEntered(Event event) {
Button button = (Button)event.getSource();
if(button.isDisabled()){
validate(currentTab);
}
}
Upvotes: 1
Views: 900
Reputation: 840
I had a similar problem where I wanted to show a tooltip of a disabled field's value when the user moused over that disabled field.
I ended up putting a blank label over the disabled field and attaching a mouse event to that.
In the case of a button, you can just give the dummy label mouse transparency when the button becomes enabled so the user can click the button.
(You might even be able to bind the label's mouse transparency property to the button's enabled property but I'm not sure.)
I know this was asked a year ago but maybe it will help someone else.
Upvotes: 1