[ADDED] Checking panel hot key improvement

36 posts
Re: Checking panel hot key improvement (MS Windows)

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
I will prevent this problem, respectively, to fix the code. It does not matter.
This function shoul be:

void MyListCtrl::OnChar(wxKeyEvent& event)
{
if (!event.AltDown() && event.GetKeyCode() >='!' && event.GetKeyCode() <='z' )
return;
else event.Skip();
}

And this function now is:
.......

void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
if (!wxGetKeyState(WXK_LEFT) && !wxGetKeyState(WXK_RIGHT) && !wxGetKeyState(WXK_UP) && !wxGetKeyState(WXK_DOWN)
&& !wxGetKeyState(WXK_NUMPAD_LEFT) && !wxGetKeyState(WXK_NUMPAD_RIGHT) && !wxGetKeyState(WXK_NUMPAD_UP) && !wxGetKeyState(WXK_NUMPAD_DOWN)
&& !wxGetKeyState(WXK_PAGEDOWN) && !wxGetKeyState(WXK_END) && !wxGetKeyState(WXK_NUMPAD_PAGEUP) && !wxGetKeyState(WXK_NUMPAD_PAGEDOWN)
&& !wxGetKeyState(WXK_HOME) && !wxGetKeyState(WXK_PAGEUP) && !wxGetKeyState(WXK_NUMPAD_HOME) && !wxGetKeyState(WXK_NUMPAD_END)
&& !wxGetKeyState(WXK_TAB) && !wxGetKeyState(WXK_BACK) && !wxGetKeyState(WXK_ALT) && !wxGetKeyState(WXK_MENU)
&& !wxGetKeyState(WXK_COMMAND))
{
switch ( event.GetKeyCode())

And what do you mean "on Mac because EVT_CHAR is not a member of the wxlistctrl class."? I didn't changed any classes. It was in ver. 0.9.4.0 and should work on MAC.

Thank you for your participation.
Re: Checking panel hot key improvement (MS Windows)

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
According to the wx documentation for wxlistctrl, EVT_ONCHAR is not listed as an event for this class. It may be inheritted, and I am not saying it doesn't work on windows, but that method traps the key strokes on Mac and doesn't pass them through to the OnListKeyDown method.

Hotkeys never worked on Mac until I commented the OnChar method out.

Does it work for you that way? We can still use the origional OnChar method, I'll just have to put an if statement around it to prevent enabling it on Mac. I will however need the New stAtements so that prssing combos will not mark transactions unintentionally. I was hoping that we could share the code to reduce code clutter where possible.
Re: Checking panel hot key improvement (MS Windows)

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
The basic idea is that we must take the original code and add to the list of all the processed keys (from ! to z):

void MyListCtrl::OnChar(wxKeyEvent& event)
{
switch ( event.GetKeyCode() )
{
case 'v':
case 'V':
case 'r':
case 'R':
case 'u':
case 'U':
case 'f':
case 'F':
case 'A'
case 'B'
case 'C'
case 'D'
.....
case '!'
case '@'
......
case'z'

and add processing alt keys
Re: Checking panel hot key improvement (MS Windows)

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
I don't understand. Why do we need to process every character in the alphabet, when we are only usung a few key for control of the list?
Re: Checking panel hot key improvement (MS Windows)

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
elliswr wrote:I don't understand. Why do we need to process every character in the alphabet, when we are only usung a few key for control of the list?

I dont know but in MS Windows the mmex procesed any other key (not only d,r,f,v,u).

This leads to the problem, for example, which I described earlier:
viewtopic.php?f=5&t=573

I am sure that on the MAC you will not be able to repeat it, but on windows it is relevant.
Re: Checking panel hot key improvement (MS Windows)

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
Well, all characters should be processed by the onlistkeydown event. And the default: event.skip should take care of any other keys pressed.

The problem you noted appears to be more related to the name of qccounts. Perhaps some code that requires accounts to be more than one character would be better here.
Re: Checking panel hot key improvement (MS Windows)

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
Hi Nik,
Let's just put some if statements in and include all the code. I'm going to post a bug report on the wxWidgets site regarding the differences in the way that Mac and Windows handle the OnChar event. Later when they fix it / change it, we can go back and clean up our code.

so:
Code: Select all
#if defined (__WXMSW__)
myListCtrl::OnChar
...
#end if

...

myListCtrl::OnListKeyDown
#if defined (__WXMSW__)
...your code here....
#elseif defined (__WXMAC__)
....my code...
#end if
...



What do you think?
Re: Checking panel hot key improvement (MS Windows)

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
Guys! Code with #ifdef ... #else is ugly. Don't do that. It is better do not have hot keys than support such sources.
Re: Checking panel hot key improvement (MS Windows)

elliswr
MMEX Developer

Posts: 151
Joined: Tue May 05, 2009 2:21 am
Location: Granbury, TX
Vadim,
Is there a better way to do this? These will have to be used at some points in the code due to different locations for resources files in applications bundle and Windows / Linux executables.
Re: Checking panel hot key improvement (MS Windows)

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
You will understand why I wrote so if you read this book, gotcha #27.
http://semantics.org/cpp_gotchas/index.html.
Who is online

Users browsing this forum: No registered users and 23 guests