-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a demo that shows how to override the default behavior and some… #292
Add a demo that shows how to override the default behavior and some… #292
Conversation
I've updated this PR to be rebased on the master branch (and a few additional changes). |
@TomasMikula Is there an issue preventing you from merging this? |
This demo is quite elaborate, demonstrating many things at once. I can see how 200 lines of code can be a little too much to process for someone who just wants to override a single key combination. Maybe sometimes less is more... |
It shouldn't require internet connection to work. |
Using a template only makes sense if it is going to be reused many times. For a one-off use, using InputMap directly is effectively the same, and probably easier. |
Good point. However, if someone does indeed subclass a
I only included that to insure the link was valid. If it isn't and we don't catch it, then someone will file an issue and we could update it immediately. However, That is a good point.
Perhaps this demo should be broken up into 2-3 demos? One could show how to write a template for a subclass of |
We can just include the link in the README instead of the demo, and the same still applies (i.e. someone will file an issue). A template can really only pay off when both
When only a handful of event handlers is being defined/overridden, condition 1. does not hold. So I probably would not bother explaining templates in RichTextFX documentation. Note that even when subclassing |
Works for me. BTW, are you keeping track of all the work to be done on the ReadMe? I think the things we've discussed span 3-4 topics, but I could only recall one (explaining that STA is the base of the other flavors) when I thought about it.
Ok, that makes sense. On another point, the API is the same for |
I've updated the PR. |
|
||
EventHandler<KeyEvent> insertNewlineChar = e -> { | ||
if (e.getCode().equals(ENTER)) { | ||
area.insertText(area.getCaretPosition(), "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would want to call e.consume()
here, to prevent the event from bubbling up the scene graph. The peculiarity is that other handlers on the same Node will still be invoked.
From Handling JavaFX Events:
However, if the node that consumes the event has more than one filter or handler registered for the event, the peer filters or handlers are still executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It's fixed now.
No, but I know someone is doing that here ;) |
Ah! I thought I opened an issue for that specifically, but I couldn't find it. So, I thought I had decided against doing that. 😀 |
…uirks of the new approach: - Shows how to install an InputMap on a single instance of a node. - Shows the bug (or feature?) that can arise when one adds a handler to the node's `on[EventType]Property`.
👍 |
… quirks of the new approach:
InputMap
on[EventType]Property
.