Pointer Event Pressure Property Data Type

I was trying to use the event.pressure property for an onPointerDown event and kept getting 0 as the returned value. After some testing I realized the documentation lists the pressure as type int and a quick type(event.pressure) check confirms it to be <type 'long'>. I’m assuming this should be a float or double?

Edit: This is version 8.1.18.

Hmm. The autocomplete is ‘wrong’ because the JS type is ‘number’ and there’s no direct analog for that in Python (JS numbers are effectively doubles, but more often than not used as integers).

That said, a quick test on my (non touchscreen) device gave me a float value for pressure when I clicked, so I don’t think the underlying mechanism is wrong here:

{
    "altKey": false,
    "bubbles": true,
    "button": 0,
    "buttons": 1,
    "cancelable": true,
    "clientX": 512,
    "clientY": 163,
    "ctrlKey": false,
    "defaultPrevented": false,
    "detail": 0,
    "eventPhase": 3,
    "height": 1,
    "isPrimary": true,
    "isTrusted": true,
    "metaKey": false,
    "movementX": 0,
    "movementY": 0,
    "pageX": 512,
    "pageY": 163,
    "pointerId": 1,
    "pointerType": "mouse",
    "pressure": 0.5,
    "screenX": 960,
    "screenY": 247,
    "shiftKey": false,
    "tangentialPressure": 0,
    "tiltX": 0,
    "tiltY": 0,
    "timeStamp": 241849.3999999985,
    "twist": 0,
    "type": "pointerdown",
    "width": 1
}

Can you test on different hardware? Can you confirm that the pressure property is set on the websocket message sent from the frontend to the backend (via browser devtools, you can watch the traffic)?

1 Like

I can confirm that I get the same 0.5 pressure value when I use a mouse or trackpad through Chrome/Safari on my Mac. Where I keep getting a value of 0 is on my iPad using standard touchscreen controls. I checked both in the Perspective app (v1.0.3-3) and in the Chrome app (103.0.5060.63).

Is there a simple way to monitor the web socket message from an iPad?

This all seems correct.

For hardware that does not support pressure, such as a mouse, the value is 0.5 when the pointer is active buttons state and 0 otherwise.

The iPad doesn’t support pressure unless you’re using a stylus and even then I’m not sure about in the browser…

1 Like

Oh interesting…in my mind I just assumed the iPad supported pressure.

I was hoping to use that as a way to prevent errant light touches from triggering events on components that do not have an associated actionPerformed event. Back to the drawing board.