[ADDED] Checking panel hot key improvement
Moderator: Renato
-
- 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)
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.
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.
-
- 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)
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:
What do you think?
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)
Guys! Code with #ifdef ... #else is ugly. Don't do that. It is better do not have hot keys than support such sources.
-
- 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)
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.
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)
You will understand why I wrote so if you read this book, gotcha #27.
http://semantics.org/cpp_gotchas/index.html.
http://semantics.org/cpp_gotchas/index.html.
-
- 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)
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 557 times
-
- 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)
Yep, that breaks hotkeys on Mac. The only thing that allows hotkeys to work is when I edit out the OnChar method.
-
- 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)
And if we make a bit change in the mmcheckingpanel.cpp:
???
PS Please, say YES
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
-
- 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)
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
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
-
- 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)
Hi wes,
Good news, thanks.
Regards,
Nikolay
Good news, thanks.
Regards,
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)
Updated to SVN revision 479.
- Attachments
-
- cp_hotkeys.zip
- (1.08 KiB) Downloaded 537 times