How to capture key events on a WCartesianChart ?
Added by Christophe Delépine over 1 year ago
Hi,
I don't manage to capture key events on a WCartesianChart.
I need this functionality to delete a selected marker on a 2D curve.
What's the trick ?
Regards
Christophe
Replies
RE: How to capture key events on a WCartesianChart ? - Added by Koen Deforche over 1 year ago
Hey,
This will in general not work since you cannot give focus to a chart. HTML5 will solve this with support for focus for every kind of widget. This is already implemented in several browsers (IE, Firefox, ...) and can be enabled by giving the widget tabindex=0. You could do this using setAttributeValue.
The alternative is to listen globally for key evens using WApplication::globalKeyPressed()
Regards
koen
RE: How to capture key events on a WCartesianChart ? - Added by Christophe Delépine over 1 year ago
Koen,
Your suggestion for setAttributeValue works indeed.
However, i cannot capture the Delete key. In fact, most of the special keys are not captured :
Key_PageUp = 33, //!< Page up key. Key_PageDown = 34, //!< Page down key. Key_End = 35, //!< End key. Key_Home = 36, //!< Home key. Key_Left = 37, //!< Left arrow key. Key_Up = 38, //!< Up arrow key. Key_Right = 39, //!< Right arrow key. Key_Down = 40, //!< Down arrow key. Key_Insert = 45, //!< Insert key. Key_Delete = 46, //!< Delete key.
Is it normal ?
Regards
Christophe
RE: How to capture key events on a WCartesianChart ? - Added by Koen Deforche over 1 year ago
Hey Christophe,
You can only catch these key events in keyWentUp() and keyWentDown() signals.
Regards,
koen
RE: How to capture key events on a WCartesianChart ? - Added by Christophe Delépine over 1 year ago
Thanks !