0

我正在尝试解决使用 AvaloniaUI 构建的应用程序中按钮的问题,该应用程序适用于在 Linux 上运行的触摸设备。

我对现有按钮的问题是:当用户用手指触摸按钮并按住时,事件会在用户按住按钮时重复,这不是所需的行为。我想强制用户每次想要触发事件时触摸按钮。

我不确定这种触摸处理是否可用。这是我的代码:XAML:

... 
<Button Name="btnIncrement" Content="Increment" />
<Label Name="lblCount" />
...

C#代码:

...
btn = this.FindName<Button>("btnIncrement");
lbl = this.FindName<Label>("lblCount");
...
private void btnClick(object sernder, RoutedEventArgs e)
{
   lblCount.Content = ++Counter;
}

更新 这是evtest当我将手指放在按钮(通常是屏幕)上时命令的输出,我也可以看到单击屏幕上重复的按钮的效果。

No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0:  mXT Touch Sensor
Select the device event number [0-0]: 0
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "mXT Touch Sensor"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min        0
      Max     1023
    Event code 1 (ABS_Y)
      Value      0
      Min        0
      Max      599
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max       30
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        2
    Event code 48 (ABS_MT_TOUCH_MAJOR)
      Value      0
      Min        0
      Max      255
    Event code 52 (ABS_MT_ORIENTATION)
      Value      0
      Min        0
      Max      255
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     1023
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max      599
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max       30
Properties:
  Property type 1 (INPUT_PROP_DIRECT)
Testing ... (interrupt to exit)
Event: time 1627091349.970937, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 312
Event: time 1627091349.970937, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 134
Event: time 1627091349.970937, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 36
Event: time 1627091349.970937, -------------- SYN_REPORT ------------
Event: time 1627091350.037757, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091350.037757, -------------- SYN_REPORT ------------
Event: time 1627091350.059211, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 313
Event: time 1627091350.059211, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 129
Event: time 1627091350.059211, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 40
Event: time 1627091350.059211, -------------- SYN_REPORT ------------
Event: time 1627091350.108717, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091350.108717, -------------- SYN_REPORT ------------
Event: time 1627091350.130538, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 314
Event: time 1627091350.130538, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 127
Event: time 1627091350.130538, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 36
Event: time 1627091350.130538, -------------- SYN_REPORT ------------
Event: time 1627091350.816930, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091350.816930, -------------- SYN_REPORT ------------
Event: time 1627091350.838510, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 315
Event: time 1627091350.838510, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 130
Event: time 1627091350.838510, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 32
Event: time 1627091350.838510, -------------- SYN_REPORT ------------
Event: time 1627091351.204381, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091351.204381, -------------- SYN_REPORT ------------
Event: time 1627091351.225845, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 316
Event: time 1627091351.225845, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 138
Event: time 1627091351.225845, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 35
Event: time 1627091351.225845, -------------- SYN_REPORT ------------
Event: time 1627091351.317391, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091351.317391, -------------- SYN_REPORT ------------
Event: time 1627091351.338715, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 317
Event: time 1627091351.338715, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 152
Event: time 1627091351.338715, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 24
Event: time 1627091351.338715, -------------- SYN_REPORT ------------
Event: time 1627091351.658090, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 131
Event: time 1627091351.658090, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 35
Event: time 1627091351.658090, -------------- SYN_REPORT ------------
Event: time 1627091351.671549, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 129
Event: time 1627091351.671549, -------------- SYN_REPORT ------------
Event: time 1627091351.678810, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 127
Event: time 1627091351.678810, -------------- SYN_REPORT ------------
Event: time 1627091351.867264, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 138
Event: time 1627091351.867264, -------------- SYN_REPORT ------------
Event: time 1627091351.874466, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 139
Event: time 1627091351.874466, -------------- SYN_REPORT ------------
Event: time 1627091351.888508, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 140
Event: time 1627091351.888508, -------------- SYN_REPORT ------------
Event: time 1627091351.909537, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 141
Event: time 1627091351.909537, -------------- SYN_REPORT ------------
Event: time 1627091351.951345, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091351.951345, -------------- SYN_REPORT ------------
Event: time 1627091351.979997, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 318
Event: time 1627091351.979997, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 129
Event: time 1627091351.979997, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 29
Event: time 1627091351.979997, -------------- SYN_REPORT ------------
Event: time 1627091352.071894, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.071894, -------------- SYN_REPORT ------------
Event: time 1627091352.294553, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 319
Event: time 1627091352.294553, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 144
Event: time 1627091352.294553, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 36
Event: time 1627091352.294553, -------------- SYN_REPORT ------------
Event: time 1627091352.517442, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.517442, -------------- SYN_REPORT ------------
Event: time 1627091352.549481, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 320
Event: time 1627091352.549481, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 145
Event: time 1627091352.549481, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 41
Event: time 1627091352.549481, -------------- SYN_REPORT ------------
Event: time 1627091352.591606, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.591606, -------------- SYN_REPORT ------------
Event: time 1627091352.656656, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 321
Event: time 1627091352.656656, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 133
Event: time 1627091352.656656, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 35
Event: time 1627091352.656656, -------------- SYN_REPORT ------------
Event: time 1627091352.716603, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.716603, -------------- SYN_REPORT ------------
Event: time 1627091352.745165, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 322
Event: time 1627091352.745165, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 141
Event: time 1627091352.745165, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 38
Event: time 1627091352.745165, -------------- SYN_REPORT ------------
Event: time 1627091352.779854, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.779854, -------------- SYN_REPORT ------------
Event: time 1627091352.830165, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 323
Event: time 1627091352.830165, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 149
Event: time 1627091352.830165, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 34
Event: time 1627091352.830165, -------------- SYN_REPORT ------------
Event: time 1627091352.903828, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091352.903828, -------------- SYN_REPORT ------------
Event: time 1627091352.929689, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 324
Event: time 1627091352.929689, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 129
Event: time 1627091352.929689, -------------- SYN_REPORT ------------
Event: time 1627091353.335710, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091353.335710, -------------- SYN_REPORT ------------
Event: time 1627091353.357271, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 325
Event: time 1627091353.357271, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 132
Event: time 1627091353.357271, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 36
Event: time 1627091353.357271, -------------- SYN_REPORT ------------
Event: time 1627091353.487983, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1627091353.487983, -------------- SYN_REPORT ------------
4

0 回答 0