Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Callback and moving cursor by arrows key
Callback and moving cursor by arrows key [message #6951] Tue, 05 December 2006 20:45 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
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
Re: Callback and moving cursor by arrows key [message #6955 is a reply to message #6951] Tue, 05 December 2006 21:55 Go to previous messageGo to next message
Werner is currently offline  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 #6958 is a reply to message #6955] Tue, 05 December 2006 22:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Just be careful, it is called on every cursor change, including "KillCursor"....

But overall over time, it proved to be the best of them (ArrayCtrl Callbacks).

Mirek
Re: Callback and moving cursor by arrows key [message #6960 is a reply to message #6955] Tue, 05 December 2006 23:55 Go to previous message
forlano is currently offline  forlano
Messages: 1185
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 Laughing

Luigi

[Updated on: Tue, 05 December 2006 23:57]

Report message to a moderator

Previous Topic: horizontal scroll
Next Topic: GridCtrl: how to disable the past at a given row
Goto Forum:
  


Current Time: Tue Apr 23 08:36:30 CEST 2024

Total time taken to generate the page: 0.01512 seconds