当前位置: 首页>>代码示例>>C++>>正文


C++ wxKeyEvent::DoAllowNextEvent方法代码示例

本文整理汇总了C++中wxKeyEvent::DoAllowNextEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ wxKeyEvent::DoAllowNextEvent方法的具体用法?C++ wxKeyEvent::DoAllowNextEvent怎么用?C++ wxKeyEvent::DoAllowNextEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxKeyEvent的用法示例。


在下文中一共展示了wxKeyEvent::DoAllowNextEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnCharHook

void wxButton::OnCharHook(wxKeyEvent& event)
{
    // We want to ensure that the button always processes Enter key events
    // itself, even if it's inside some control that normally takes over them
    // (this happens when the button is part of an in-place editor control for
    // example).
    if ( event.GetKeyCode() == WXK_RETURN )
    {
        // We should ensure that subsequent key events are still generated even
        // if we did handle EVT_CHAR_HOOK (normally this would suppress their
        // generation).
        event.DoAllowNextEvent();
    }
    else
    {
        event.Skip();
    }
}
开发者ID:Anonymous2,项目名称:project64,代码行数:18,代码来源:button.cpp

示例2: OnCharHook

    void OnCharHook( wxKeyEvent& aEvent )
    {
        // On certain platforms, EVT_CHAR_HOOK is the only handler that receives
        // certain "special" keys. However, it doesn't always receive "normal"
        // keys correctly. For example, with a US keyboard, it sees ? as shift+/.
        //
        // Untangling these incorrect keys would be too much trouble, so we bind
        // both events, and simply skip the EVT_CHAR_HOOK if it receives a
        // "normal" key.

        const enum wxKeyCode skipped_keys[] =
        {
            WXK_NONE,    WXK_SHIFT,  WXK_ALT, WXK_CONTROL, WXK_CAPITAL,
            WXK_NUMLOCK, WXK_SCROLL, WXK_RAW_CONTROL
        };

        int key = aEvent.GetKeyCode();

        for( size_t i = 0; i < sizeof( skipped_keys ) / sizeof( skipped_keys[0] ); ++i )
        {
            if( key == skipped_keys[i] )
                return;
        }

        if( key <= 255 && isprint( key ) && !isspace( key ) )
        {
            // Let EVT_CHAR handle this one
            aEvent.DoAllowNextEvent();

            // On Windows, wxEvent::Skip must NOT be called.
            // On Linux and OSX, wxEvent::Skip MUST be called.
            // No, I don't know why.
#ifndef __WXMSW__
            aEvent.Skip();
#endif
        }
        else
        {
            OnChar( aEvent );
        }
    }
开发者ID:nakijun,项目名称:kicad-source-mirror,代码行数:41,代码来源:widget_hotkey_list.cpp

示例3: OnChar

void FrequencyDialog::OnChar(wxKeyEvent& event) {
    int c = event.GetKeyCode();
    long long freq;
    std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();

    switch (c) {
    case WXK_RETURN:
    case WXK_NUMPAD_ENTER:
        // Do Stuff
        freq = strToFrequency(dialogText->GetValue().ToStdString());

        if (targetMode == FDIALOG_TARGET_DEFAULT) {
            if (activeDemod) {
                activeDemod->setTracking(true);
                activeDemod->setFollow(true);
                activeDemod->setFrequency(freq);
                activeDemod->updateLabel(freq);
            } else {
                wxGetApp().setFrequency(freq);
            }
        }
        if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
            if (lastDemodType == "USB" || lastDemodType == "LSB") {
                freq *= 2;
            }
            if (activeDemod) {
                activeDemod->setBandwidth(freq);
            } else {
                wxGetApp().getDemodMgr().setLastBandwidth(freq);
            }
        }
        Close();
        break;
    case WXK_ESCAPE:
        Close();
        break;
    }

    std::string allowed("0123456789.MKGHZmkghz");

    if (allowed.find_first_of(c) != std::string::npos || c == WXK_DELETE || c == WXK_BACK || c == WXK_NUMPAD_DECIMAL
            || (c >= WXK_NUMPAD0 && c <= WXK_NUMPAD9)) {
#ifdef __linux__
        dialogText->OnChar(event);
        event.Skip();
#else
        event.DoAllowNextEvent();
#endif
    } else if (event.ControlDown() && c == 'V') {
        // Alter clipboard contents to remove unwanted chars
        wxTheClipboard->Open();
        wxTextDataObject data;
        wxTheClipboard->GetData(data);
        std::string clipText = data.GetText().ToStdString();
        std::string pasteText = filterChars(clipText, std::string(allowed));
        wxTheClipboard->SetData(new wxTextDataObject(pasteText));
        wxTheClipboard->Close();
        event.Skip();
    } else if (c == WXK_RIGHT || c == WXK_LEFT || event.ControlDown()) {
        event.Skip();
    }
}
开发者ID:viraptor,项目名称:CubicSDR,代码行数:62,代码来源:FrequencyDialog.cpp


注:本文中的wxKeyEvent::DoAllowNextEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。