wxGridSizer/wxPanel :使左/右导航键表现得像 shift-tab/tab [英] wxGridSizer / wxPanel : make left/right navigation key behave like shift-tab/tab

查看:35
本文介绍了wxGridSizer/wxPanel :使左/右导航键表现得像 shift-tab/tab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 wxWidget.我有带有 4 个按钮的 panel 并使用 wxGridSizer 将它们放在网格中.当我转到该行最右边的单元格并按 Right key 时,焦点仍停留在同一个小部件上.我可以设置一些属性,其中 Right/Left 位于角落的键用作 Tab 和 shift-tab.

I am using a wxWidget. I have panel with 4 buttons and using wxGridSizer to put them in grid. When i go to the rightmost cell of the row and press Right key, focus remains on the same widget. Can i set some property where Right/Left keys at corner works as tab and shift-tab.

我想要的是,用户应该能够通过按左右键circle 穿过 4 个按钮.我想将向上/向下键用于其他目的.

What i want is that user should be able to circle through the 4 buttons by just pressing left and right keys. I want to use up/down keys for other purpose.

如果有帮助,这里是代码:

Here is the code if it helps :

#include <wx/wx.h>
#include <wx/grid.h>
#include <wx/sizer.h>
#include <wx/string.h>

#include <iostream>
#include <cassert>

class ReachItFrame : public wxFrame
{
public:
  ReachItFrame(const wxString& title) : wxFrame()
  {
    Create(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150));
  }
};

class MyApp : public wxApp
{
public:
  bool OnInit()
  {
    ReachItFrame *reachIt = new ReachItFrame(wxT("ReachIt"));
    reachIt->Show(true);
    assert(reachIt->SetTransparent(150));
    assert(reachIt->ShowFullScreen(true, wxFULLSCREEN_ALL));

    wxPanel *panel = new wxPanel(reachIt);
    wxGridSizer *sizer = new wxGridSizer(2, 2, 0, 0);

    wxButton *button1 = new wxButton(panel, wxID_ANY, wxString::FromAscii("1"));
    sizer->Add(button1, wxSizerFlags().Expand());

    wxButton *button2 = new wxButton(panel, wxID_ANY, wxString::FromAscii("2"));
    sizer->Add(button2, wxSizerFlags().Expand());

    wxButton *button3 = new wxButton(panel, wxID_ANY, wxString::FromAscii("3"));
    sizer->Add(button3, wxSizerFlags().Expand());

    wxButton *button4 = new wxButton(panel, wxID_ANY, wxString::FromAscii("4"));
    button4->MoveBeforeInTabOrder(button3);
    sizer->Add(button4, wxSizerFlags().Expand());

    panel->SetSizerAndFit(sizer);

    return true;
  }
};

wxIMPLEMENT_APP(MyApp);

推荐答案

没有对此的内置支持,但您可以自己捕捉 WXK_RIGHTWXK_LEFT你的 wxEVT_CHAR 处理程序并在那里做任何你想做的事情.您可以查看 wxGrid::DoGridProcessTab() 以获取您可能想要执行的操作的示例,例如注意这里使用的帮助器 MoveCursor{Left,Right}()GoToCell() 方法.

There is no built-in support for this, but you can catch WXK_RIGHT and WXK_LEFT yourself in your wxEVT_CHAR handler and do whatever you want there. You can look at wxGrid::DoGridProcessTab() for an example of what you might want to do, e.g. notice the helper MoveCursor{Left,Right}() and GoToCell() methods used there.

这篇关于wxGridSizer/wxPanel :使左/右导航键表现得像 shift-tab/tab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆