wxDataViewCtrl, arrow keys Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

wxDataViewCtrl, arrow keys

Post by spectrum » Mon Dec 07, 2009 1:35 pm

Hi all,

Keyboard up/down cause the up/down selection of the item.
is there a way to disable the action of arrows keys ?

many thanks
spectrum

JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway » Mon Dec 07, 2009 4:49 pm

Hi,

I don't think there's a config option to do this, and the routine to handle keys is not virtual (I think more of them should be...)

But the following code added to the sample does the trick for the left dataview object:

Code: Select all

void MyFrame::OnChar(wxKeyEvent &event)
{
	if (event.GetKeyCode() != WXK_UP)			// trap the key up, add others as you see fit...
		event.Skip();
}
The handler is installed for the target window using connect as follows:

Code: Select all

// Left wxDataViewCtrl
dataview_left = new wxDataViewCtrl( panel, wxID_ANY );
dataview_left->GetTargetWindow()->Connect(wxID_ANY,wxEVT_CHAR,wxKeyEventHandler(MyFrame::OnChar),0,this);
Hope that helps,

Jim
OS: Vista SP1, wxWidgets 2.8.7.

spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum » Wed Dec 09, 2009 12:50 pm

many thanks, i will try this way.
spectrum

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Wed Dec 09, 2009 3:31 pm

Please accept the post that helped you, not your own
"Keyboard not detected. Press F1 to continue"
-- Windows

Post Reply