Check for direction key press in TextEditorComponent()?


#1

I’m trying to find a way to intercept presses to the direction keys in the TextEditorComponent but since not text has changed they don’t get picked up in the usual channels. I wonder could a handleDirectionKey() be added to the other TextEditorComponent handle methods?


#2

Don’t want to bloat it too much with callbacks like that… Can’t you override keyPressed?


#3

I’ll take a look…


#4

CodeEditorComponent::keyPressed isn’t virtual?


#5

CodeEditorComponent inherits Component in which keyPressed is virtual. You can’t un-virtualise a method even if the virtual keyword isn’t explicitly specified.

Now of course that has recently changed in C++11 with the ‘final’ keyword in which you can stop a function from being overridden but that isn’t applicable here. If you’re not getting the callback make sure your constness matches the base implementation.


#6

Thanks Dave. Another lesson learned!