Page 1 of 2

[ADDED] Checking panel hot key improvement

Posted: Sat Sep 05, 2009 8:13 pm
by Nikolay
Hi,

With this correction, keystrokes in the checking panel will be work better.

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 12:08 am
by elliswr
I was just checking out the latest rev to make sure that everything still works ant to check out this new file. I noticed that many files have been changed, but I am not sure which ones to use. For example there's a appstartdialog.cpp, appstartdialog.cpp.mine, appstartdialog.cpp.r402, and appstartdialog.cpp.407.

Which one should I be using and what is the difference in all of these?

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 4:25 am
by elliswr
So I figured that out after some reading at different svn sites. Each time that I checkout from the svn repository, the changed files are not replaced, but quasi merged and given different endings. Simple fix was to delete and checkout again.

I have tried out the patch and Mac hotkeys still do not work, but it compiles just fine. So if it works on the windows side, it does not hurt on the mac side.

This hotkey bug is giving me quite a time. The only hotkeys that work are the Control+O for open database, Control+N for new database and the Control+Q for quit (may be CTRL+X on windows). These work because the menu hotkeys are translated automatically by wxMac to be read as Command+O /N/Q.

As for the regular checking panel keys (V, C, D, F, R) the only ones that work is D and Delete. If anyone has any ideas, fill me in. I'll keep working on this for the next release.

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 4:35 am
by elliswr
I take that back. Now only Delete works, but it really doesn't affect the Mac house significantly.

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 4:54 am
by elliswr
Hey, for all package maintainers:

When you build wxWidgets, do you use ANSI or UNICODE? Does anyone think this bug could be due to my using ASNII?

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 6:01 am
by Nikolay
I found a very interesting resource (but in Russian):
http://wxwidgets.info/perevod-knigi-jul ... stv-vvoda/
This is a translation of the book Julian Smart "Processing of data from input devices."
Try to find the oroginal. Let us examine. :)

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 6:41 am
by Nikolay
Hi,

Check, please, this patch.

Re: Checking panel hot key improvement

Posted: Tue Sep 08, 2009 11:08 am
by elliswr
Hey Nik, You've got something there!

I don't know why but now Command+F, Command+R, Command+V, and Command+D all mark the transaction appropriately, although, I am not sure that is what you intended, but that's the change that I got.

I don't have the time to do it now, but tonight, hopefully...

Re: Checking panel hot key improvement

Posted: Thu Sep 10, 2009 10:43 am
by Nikolay
Hi Wes,

There are success in processing the buttons on the Mac?

Re: Checking panel hot key improvement

Posted: Thu Sep 10, 2009 11:16 am
by elliswr
Sort of, but not in the way that the code is written, so I am still looking into it.

Re: Checking panel hot key improvement

Posted: Thu Sep 10, 2009 10:48 pm
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.

Re: Checking panel hot key improvement

Posted: Thu Sep 10, 2009 11:00 pm
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?

Re: Checking panel hot key improvement

Posted: Thu Sep 10, 2009 11:26 pm
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

Re: Checking panel hot key improvement (MS Windows)

Posted: Wed Sep 16, 2009 1:04 pm
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.

Re: Checking panel hot key improvement (MS Windows)

Posted: Wed Sep 16, 2009 5:38 pm
by Nikolay
Hi Wes,

Could you kindly check my last creation?

Re: Checking panel hot key improvement (MS Windows)

Posted: Thu Sep 17, 2009 12:05 am
by elliswr
Nik,
The patch fails against the current trunk version. Could you attach the mmcheckingpanel.cpp file?

Re: Checking panel hot key improvement (MS Windows)

Posted: Thu Sep 17, 2009 3:56 am
by Nikolay

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 2:28 am
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:

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 6:53 am
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.

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 2:29 pm
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.

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 4:14 pm
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.

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 4:33 pm
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.

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 4:39 pm
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

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 4:46 pm
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?

Re: Checking panel hot key improvement (MS Windows)

Posted: Fri Sep 18, 2009 4:58 pm
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.