Mouse event filters for agenda and appointment

164 views
Skip to first unread message

Maciej Domagała

unread,
Dec 22, 2014, 5:15:35 AM12/22/14
to jfxtr...@googlegroups.com
Hi :)
I'm writing a simple calendar app and I want to add two mouse event filters - one for agenda (double click on calendar field opens new window) and one for appointment (double click on appointment opens edit window). I'm kinda new to javaFX and javaFXtras and I was wondering if stuff like this is already implemented in your library? 
I wrote my own appointment class which extends Control class and implements Appointment interface, but when I use mouse on Agenda/appointment it always shows Agenda as MouseEvent source and I cannot "reach" appointment.


TL:DR - Is there any way I can check what is MouseEvent source - Agenda or Appointment - for events like double click etc.?

tbee

unread,
Dec 22, 2014, 5:46:22 AM12/22/14
to jfxtr...@googlegroups.com
For an alternative to the popup window is a hook available in agenda, that could be a possible approach. I would not try to hook into the skin, I'm currently busy with a major refactoring of the skin and I do not consider people extending that. The skin class is "internal" code.

That said, double click seems like a good trigger to open en edit window.

Regards, Tom

Maciej Domagała

unread,
Dec 22, 2014, 7:22:48 AM12/22/14
to jfxtr...@googlegroups.com
Thanks for answer, Tom. Unfortunately I do not understand what "a hook" is. Can you tell me which method should I use to know when I double click an Appointment? Sorry for my stupidity, but I'm new to javaFX as I said ;)

tbeernot

unread,
Dec 22, 2014, 9:07:04 AM12/22/14
to jfxtr...@googlegroups.com
The skin has a default implementation for an edit event (the popup), if you would like to provide your own, you can set a callback in agenda's setEditAppointmentCallback() method. This is a "hook" (nothing JavaFX specific there) to insert your own logic to replace the default.

Since Agenda will be having more skins, triggering on a double click is not a good idea. Who knows how appointments will be rendered in the other skins? Rendering and handling of the mouse is internal to the control and agenda will never expose a "double click" event. You could inspect the nodes the control uses, and register directly to those, but chances are high your code will break. But, as described above, agenda has an "edit appointment" event, which now is bound to the menu in the top left corner of each appointment. I could also trigger this on double click. That seems intuitive.

TL;DR: get "double click" out of your head, there only are "add" and "edit" events.

Tom

tbeernot

unread,
Dec 22, 2014, 10:12:54 AM12/22/14
to jfxtr...@googlegroups.com
In the refactoring I'm doing I've added a action callback on agenda, which for the current skin is bound to the double click. I will be merging the refactoring to the master very soon.

Tom
Reply all
Reply to author
Forward
0 new messages