[ADDED] Checking panel hot key improvement

Money Manager Ex Development related posts
(http://github.moneymanagerex.org/)

Moderator: Renato

Nikolay
MMEX Developer
Posts: 1377
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: Checking panel hot key improvement (MS Windows)

Post by Nikolay »

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.

elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

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.

Nikolay
MMEX Developer
Posts: 1377
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: Checking panel hot key improvement (MS Windows)

Post by Nikolay »

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

elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

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?

Nikolay
MMEX Developer
Posts: 1377
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: Checking panel hot key improvement (MS Windows)

Post by Nikolay »

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:
http://www.codelathe.com/forum/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.

elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

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.

elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

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?

Vadim
MMEX Developer
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Checking panel hot key improvement (MS Windows)

Post by Vadim »

Guys! Code with #ifdef ... #else is ugly. Don't do that. It is better do not have hot keys than support such sources.

elliswr
MMEX Developer
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX
Contact:

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

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.

Vadim
MMEX Developer
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Checking panel hot key improvement (MS Windows)

Post by Vadim »

You will understand why I wrote so if you read this book, gotcha #27.
http://semantics.org/cpp_gotchas/index.html.

Post Reply