【问题标题】:Bind number key (numeric keypad)绑定数字键(数字小键盘)
【发布时间】:2018-06-11 07:17:05
【问题描述】:

我正在尝试制作一个精美的计算器(使用按钮小部件)。

必须输入数字键(如 1,2,3 或 num1,num2)。

所以我就这样尝试

bind . <key 1> {multiply $numberKey}

bind . <1> {multiply $numberKey}

但它不起作用。

如何绑定数字键?

【问题讨论】:

    标签: input event-handling tcl keypad


    【解决方案1】:

    1键的名字是1没有&lt;…&gt;围绕它。

    bind . 1 {puts "pressed one"}
    

    您也可以使用全名,该名称需要描述为KeyPress 事件(如果需要,可以缩短为Key):

    bind . <KeyPress-1> {puts "pressed one"}
    

    要获取任意键的名称,请尝试以下小脚本:

    bind . <KeyPress> {puts "pressed %K (producing character %A)"}
    

    当您按下键时,它会打印键的名称(您需要使用 KeyPress 前缀作为描述的名称)。可以直接使用单字符键符,但不能只在 &lt;…&gt; 中输入数字,因为这在特殊情况下表示按下鼠标按钮(因为在大多数应用程序中更常见的是专门绑定的)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-19
      • 1970-01-01
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多