Beispiel #1
0
bool Dialog::PreprocessMessage(const KeyMessage& message) {

    if (message.id == WM_KEYDOWN) {

        if ((message.GetVirtualKey() == VK_RETURN) || (message.GetVirtualKey() == VK_ESCAPE)) {

            auto focused_control = GetFocusedControl();
            if ((focused_control != nullptr) && focused_control->AcceptKeyMessage(message)) {
                return false;
            }

            if (message.GetVirtualKey() == VK_ESCAPE) {
                CloseWithResult(DialogResult::Cancel);
                return true;
            }
            
            //VK_RETURN
            if (current_default_button_ != nullptr) {
                if (current_default_button_->GetWindow().get() == this) {
                    current_default_button_->Click();
                    return true;
                }
            }
        }
    }

    return __super::PreprocessMessage(message);
}
Beispiel #2
0
bool ComboBox::KeyDown(const KeyMessage& message) {

    auto key = message.GetVirtualKey();
    if ((key == VK_UP) || (key == VK_DOWN)) {

        if (SelectNextDropDownListItem(key == VK_UP)) {
            return true;
        }
    }
    else if (key == VK_RETURN) {

        EnterKeyDown();
        return true;
    }
    else if (key == VK_SPACE) {
        
        //The edit text box processes the space key down event,
        //but it still delivers this event to here, then click event
        //of clickable control triggered. So omit the event to 
        //prevent this problem.
        if (IsEditable()) {
            return true;
        }
    }
    
    return __super::KeyDown(message);
}
Beispiel #3
0
bool ComboBox::EditTextBox::KeyDown(const KeyMessage& message) {

    auto key = message.GetVirtualKey(); 
    if (key == VK_UP || key == VK_DOWN || key == VK_RETURN) {

        //Call the default handler to derives the event to its parent - combo box.
        return Control::KeyDown(message);
    }
    else {
        return __super::KeyDown(message);
    }
}