【问题标题】:How to map Esc to an action in a Motif widget如何将 Esc 映射到 Motif 小部件中的操作
【发布时间】:2021-04-05 05:50:25
【问题描述】:

这个最小的例子创建了一个带有按钮小部件的 Motif 窗口。

#include <Xm/PushB.h>

int main(int argc, char **argv) {
  XtAppContext app;
  Widget       toplevel, b;
  char         *translations="<Key>Escape: ArmAndActivate()\n\
                              <Key>a:      ArmAndActivate()";

  toplevel = XtVaOpenApplication(&app, "tl", NULL, 0, &argc, argv, NULL,
                                 sessionShellWidgetClass, NULL);
  
  b = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, toplevel, NULL);
  XtOverrideTranslations(b, XtParseTranslationTable(translations));

  XtRealizeWidget(toplevel);
  XtAppMainLoop(app);
  return(0);
}

Esca 都映射到同一个动作, ArmAndActivate,但小部件只响应 a 按键,不响应 Esc如何让它响应 Esc 请注意 根据xevEscape 确实是正确的键符。

【问题讨论】:

    标签: c keyboard-shortcuts motif


    【解决方案1】:

    Escape is the osfCancel Motif virtual binding;从这个意义上说 已经“占领”了。所以使用

    <Key>osfCancel: ArmAndActivate()
    

    可以通过~/.motifbind 文件修改虚拟绑定,请参阅The Motif Programming Modelman VirtualBindings

    【讨论】:

      猜你喜欢
      • 2016-02-21
      • 1970-01-01
      • 2014-09-06
      • 1970-01-01
      • 2020-11-28
      • 2016-11-28
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      相关资源
      最近更新 更多