Page 1 of 1

UP/DOWN keys binding for checking panel

Posted: Sat Dec 17, 2011 11:50 pm
by Nikolay

Code: Select all

    void onChoiceTransChar (wxKeyEvent& event);
    void onChoiceStatusChar (wxKeyEvent& event);

Code: Select all

    choiceStatus_->Connect(ID_DIALOG_TRANS_STATUS, wxEVT_CHAR, wxKeyEventHandler(mmTransDialog::onChoiceStatusChar), NULL, this);
...
    choiceTrans_->Connect(ID_DIALOG_TRANS_TYPE, wxEVT_CHAR, wxKeyEventHandler(mmTransDialog::onChoiceTransChar), NULL, this);
...
void mmTransDialog::onChoiceTransChar(wxKeyEvent& event)
{   
	wxChoice* choice = (wxChoice*)FindWindow(ID_DIALOG_TRANS_TYPE);
    int i = choice->GetSelection();
    if (event.GetKeyCode()==WXK_DOWN) {
	    if (i < DEF_TRANSFER)
	        choice->SetSelection(++i);
} else if (event.GetKeyCode()==WXK_UP){
	    if (i > DEF_WITHDRAWAL)
	        choice->SetSelection(--i);
}
        updateControlsForTransType();
        event.Skip(); 
}
void mmTransDialog::onChoiceStatusChar(wxKeyEvent& event)
{   
	wxChoice* choice = (wxChoice*)FindWindow(ID_DIALOG_TRANS_STATUS);
    int i = choice->GetSelection();
    if (event.GetKeyCode()==WXK_DOWN) {
	    if (i < DEF_STATUS_DUPLICATE)
	        choice->SetSelection(++i);
    } else if (event.GetKeyCode()==WXK_UP){
	    if (i > DEF_STATUS_NONE)
	        choice->SetSelection(--i);
    }
        event.Skip(); 
}