Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Callback and moving cursor by arrows key
|
Re: Callback and moving cursor by arrows key [message #6955 is a reply to message #6951] |
Tue, 05 December 2006 21:55   |
Werner
Messages: 234 Registered: May 2006 Location: Cologne / Germany
|
Experienced Member |
|
|
forlano wrote on Tue, 05 December 2006 20:45 | Hello,
I move the cursor of the arrayctrl by using the up and down arrow keys. I would like to intercept this action. None of the existing When* works. Perhaps I missed something or I need to override WhenBar?
Luigi
|
What about
...
void OnCursor()
{
PromptOK("Cursor moved!");
}
...
ArrayCtrl my_array_ctrl;
...
my_array_ctrl.WhenCursor = THISBACK(OnCursor);
...
?
Werner
[Updated on: Tue, 05 December 2006 22:26] Report message to a moderator
|
|
|
|
Re: Callback and moving cursor by arrows key [message #6960 is a reply to message #6955] |
Tue, 05 December 2006 23:55  |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Werner wrote on Tue, 05 December 2006 21:55 |
forlano wrote on Tue, 05 December 2006 20:45 | Hello,
I move the cursor of the arrayctrl by using the up and down arrow keys. I would like to intercept this action. None of the existing When* works. Perhaps I missed something or I need to override WhenBar?
Luigi
|
What about
...
void OnCursor()
{
PromptOK("Cursor moved!");
}
...
ArrayCtrl my_array_ctrl;
...
my_array_ctrl.WhenCursor = THISBACK(OnCursor);
...
?
Werner
|
Hi Werner,
you are right, of course. Before to post my stupid question I tried .WhenCursor but without success, the callback was not activated by moving the cursor by keyboard. After your code I've investigated better and I discovered a bug in my application. It had two supplementary line that in principle should work with the click of the mouse but prevented to work with the arrow keys! More or less this:
void OnCursor()
{ int i = my_array_ctrl.GetClickRow(); // <====
if (i<0) return; // always return by pressing the arrow keys
PromptOK("Cursor moved!");
}
The fix was trivial: substitute GetClickRow() with Getcursor().
Perhaps I should write a book of "instructive" mistakes
Luigi
[Updated on: Tue, 05 December 2006 23:57] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 14:28:22 CEST 2025
Total time taken to generate the page: 0.04935 seconds
|