[ADDED] Checking panel hot key improvement

Money Manager Ex Development related posts for both Android and Desktop

Moderator: Renato

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

Re: Checking panel hot key improvement

Post by elliswr »

So, I know this is not the code of the latest fix that you submitted, but I was having issues merging yours and Vadim's latest patches. At any rate, I got to thinking about why 'd' or 'D' worked as well as Delete for marking transactions and nothing else did. Have a look at this code:

Code: Select all

void MyListCtrl::OnChar(wxKeyEvent& event)
{
    switch ( event.GetKeyCode() )
    {
        case 'v':
        case 'V':
        case 'r':
        case 'R':
        case 'u':
        case 'U':
        case 'f':
        case 'F':
            // these are the keys we process ourselves
            break;

        default:
            event.Skip();
    }
Notice that it does not contain 'd', 'D", or Delete. So just for a go, I decidded to comment out the F's like so:

Code: Select all

void MyListCtrl::OnChar(wxKeyEvent& event)
{
    switch ( event.GetKeyCode() )
    {
        case 'v':
        case 'V':
        case 'r':
        case 'R':
        case 'u':
        case 'U':
        //case 'f':
        //case 'F':
            // these are the keys we process ourselves
            break;

        default:
            event.Skip();
    }
After building with these changes, the F, f, d, D, and Delete all work on the mac. So, I would have to say somewhere here in lies our problem.
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement

Post by elliswr »

Taking a look at the event table, I find the event that calls MyListCtrl::OnChar to be EVT_CHAR. I took a look at the wxWidgets Documentation and there is no such mention of this for a wxListCtrl. While this may be inherited, what is the point of even using this? If we just use EVT_LIST_KEY_DOWN to call OnListKeyDown and handle all of our keys there, this should work.


I've just tried it out before posting getting rid of EVT_CHAR(MyListCtrl::OnChar) all together and it works perfectly. Also, other keys pressed do not do anything, as expected.

Nikolay, could you try just getting rid of that and seeing if it works the same on Windows?
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement

Post by elliswr »

Even without this:

Code: Select all

if (!wxGetKeyState(WXK_ALT) && !wxGetKeyState(WXK_CONTROL))
All the hotkeys work as expected (not active while Control, Alt, or Command are pressed) on the mac. Not sure about windows, but the return key does't act the same, nor do arrows, so I would assume that all the others you have listed are the same.

I think if we just discriminated within OnListKeyDown, that would be the easiest fix with the least code production.

Cheers,
Wes
Nikolay
Developer
Posts: 1535
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 »

Hi,

I have checked how the hot keys work on Ubuntu (without my patch). All the hotkeys work as expected. With the participation of the keyboard Atl, Ctrl too well.

Conclusion: This patch is required only for Windows.
Nikolay
Developer
Posts: 1535
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 »

Hi Wes,

Could you kindly check my last creation?
Attachments
cp_hotkeys.zip
(709 Bytes) Downloaded 483 times
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

Nik,
The patch fails against the current trunk version. Could you attach the mmcheckingpanel.cpp file?
Nikolay
Developer
Posts: 1535
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 »

Attachments
mmcheckingpanel.zip
(9.01 KiB) Downloaded 448 times
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

Nik,
That still doesn't work on Mac because EVT_CHAR is not a member of the wxlistctrl class.

Try this out, it works mo betta on Mac:
Attachments
mmcheingpanel.zip
Good Stuff
(12.53 KiB) Downloaded 480 times
Nikolay
Developer
Posts: 1535
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 »

Hi Wes,

I have tried to do something similar, according to your recommendation. This works but badly.
For example, when you press the keys alt + V, entry is marked as Void and drops the "View" menu at the same time and the cursor escapes on the very first posting.
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

Hi Nik.

I didn't even notice it, but I forget to add WXK_ALT in the code I added:

Code: Select all

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_NUMPAD_DELETE) && !wxGetKeyState(WXK_MENU)
		&& !wxGetKeyState(WXK_COMMAND))
So, if you add

Code: Select all

&& !wxGetKeyState(WXK_ALT)
to the end of that list, it should work. Please try it out and let me know. On Mac, alt isn't used for menu navigation and I forgot about that, sorry.
Nikolay
Developer
Posts: 1535
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
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

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
Developer
Posts: 1535
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
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

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
Developer
Posts: 1535
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
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

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
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

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
Super User
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
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

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
Super User
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.
Nikolay
Developer
Posts: 1535
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 »

My last code. Are there reasons it does not work on MAC?

Code: Select all

void MyListCtrl::OnChar(wxKeyEvent& event)
{	if (wxGetKeyState(WXK_ALT) || 
		wxGetKeyState(WXK_COMMAND) ||
		wxGetKeyState(WXK_UP) || 
		wxGetKeyState(WXK_DOWN) || 
		wxGetKeyState(WXK_LEFT) || 
		wxGetKeyState(WXK_RIGHT) || 
		wxGetKeyState(WXK_HOME) || 
		wxGetKeyState(WXK_END) ||
		wxGetKeyState(WXK_PAGEUP) || 
		wxGetKeyState(WXK_PAGEDOWN) || 
		wxGetKeyState(WXK_NUMPAD_UP) ||
		wxGetKeyState(WXK_NUMPAD_DOWN) ||
		wxGetKeyState(WXK_NUMPAD_LEFT) ||
		wxGetKeyState(WXK_NUMPAD_RIGHT) ||
		wxGetKeyState(WXK_NUMPAD_PAGEDOWN) ||
		wxGetKeyState(WXK_NUMPAD_PAGEUP) ||
		wxGetKeyState(WXK_NUMPAD_HOME) ||
		wxGetKeyState(WXK_NUMPAD_END) 
		)
	event.Skip();
  }

void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
	if (!wxGetKeyState(WXK_COMMAND) && !wxGetKeyState(WXK_ALT))
 {
	switch ( event.GetKeyCode())
    {
		case WXK_DELETE:
		case WXK_NUMPAD_DELETE:
            {
                wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_DELETE);
                OnDeleteTransaction(evt);
            }
            break;

        case 'V':
            {
                wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_MARKVOID);
                OnMarkTransaction(evt);
            }
            break;

        case 'R':
            {
                wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_MARKRECONCILED);
                OnMarkTransaction(evt);
            }
            break;

        case 'U':
            {
                 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_MARKUNRECONCILED);
                 OnMarkTransaction(evt);
            }
            break;

        case 'F':
            {
                 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_MARK_ADD_FLAG_FOLLOWUP);
                 OnMarkTransaction(evt);
            }
            break;
		case 'D':
            {
                 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_MARKDUPLICATE);
                 OnMarkTransaction(evt);
			}
            break;
	
	}
	}
	event.Skip();
	
}
Attachments
HKEYS.zip
(11.05 KiB) Downloaded 547 times
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

Yep, that breaks hotkeys on Mac. The only thing that allows hotkeys to work is when I edit out the OnChar method.
Nikolay
Developer
Posts: 1535
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 »

And if we make a bit change in the mmcheckingpanel.cpp:

Code: Select all

    EVT_MENU(MENU_ON_COPY_TRANSACTION, MyListCtrl::OnCopy) 
    EVT_MENU(MENU_ON_PASTE_TRANSACTION, MyListCtrl::OnPaste) 
    EVT_MENU(MENU_ON_NEW_TRANSACTION, MyListCtrl::OnNewTransaction) 
  
#if defined (__WXMSW__)
	EVT_CHAR(MyListCtrl::OnChar)
#endif
    EVT_LIST_KEY_DOWN(ID_PANEL_CHECKING_LISTCTRL_ACCT, MyListCtrl::OnListKeyDown)
???
PS Please, say YES :)
elliswr
Super User
Posts: 102
Joined: Tue May 05, 2009 8:21 am
Are you a spam bot?: No
Location: Granbury, TX

Re: Checking panel hot key improvement (MS Windows)

Post by elliswr »

Nik,

So, you'll never believe this, but I got your code to work just fine on Mac without #if and #endif statements. You see, I broke the golden rule of troubleshooting and changed more than one thing at a time. If I edit out the OnChar method without changing anything else, keystrokes worked. So I jumped to the conclusion that it was your code that was the problem. At the same time, I was battling with the lack of response to clicks that the same wxlistctrl was giving me in mmcheckingpanel.

I found out how to implement the generic version of wxlistctrl and the clicks worked (in other words, native wxlistctrl is broken on Mac in 2.8.10). When I updated to the new source from the branch 0.9.5, I forgot to re-imlement the generic version of wxlistctrl, and thus your code wouldn't work no matter what I did. Sorry for all this, it now works on Windows and Mac.

Lets commit that code.

Wes
Nikolay
Developer
Posts: 1535
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 »

Hi wes,

Good news, thanks.

Regards,
Nikolay
Post Reply