When I hit ‘a’, it prints “event : 38 20”. However I expected the fCode to be 97. What really surprises me is that the key corresponding to 39 is not ‘b’ but ‘s’. In fact, the fCode is related to the place of the key on the keyboard !
Is it a feature ?
Anyway, how can I get a code corresponding to the char which has been hit ? Like 97 for ‘a’, 98 for ‘b’ , etc… ?
I attach a modified version of your example DND_dev. I added a slot “asdf” in MyClass and connected the signal of the TGCanvas containing the tree to this slot.
The output is the same as the one I explained in my first message. If you put the mouse over the tree and type ‘a’ you will get “38 16”… and then if you move the mouse it continues to produce the same event… which is strange as well.
I am sure I am doing a stupid mistake, but I don’t see what it is.
Thanks in advance,
Barth
PS:
the makefile can’t be attached, but it is strictly the same as the one you sent to me. rdnd2.cxx (20.1 KB) MyClass.h (483 Bytes) LinkDef.h (160 Bytes)
void TAmoreObjectManager::HandleCanvasEvents(Int_t event, Int_t x, Int_t y, TObject *selected)
{
if (event != kButton1Up && event != kButton1Double && event != kKeyPress)
return ;
cout << "event : " << event << " ; x : " << x << " ; y : " << y << endl;
// here I would like to know if the ctrl key is used or not.
}
And as a result I get event = 24 for the key events (that’s fine), and the ascii code in both x and y variables for a a simple key stroke. But if I use the ctrl modifier then I get x=26 and y=122 per instance for Ctrl-z. Moreover a hit on the delete key gives me x=127 and y=4103.
As a consequence, I am wondering if there is a clean way of knowing if a modifier key is used.