pub unsafe trait GCPressedStateInput: NSObjectProtocol {
// Provided methods
unsafe fn pressedDidChangeHandler(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>
where Self: Sized + Message { ... }
unsafe fn setPressedDidChangeHandler(
&self,
pressed_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>>,
)
where Self: Sized + Message { ... }
unsafe fn isPressed(&self) -> bool
where Self: Sized + Message { ... }
unsafe fn lastPressedStateTimestamp(&self) -> NSTimeInterval
where Self: Sized + Message { ... }
unsafe fn lastPressedStateLatency(&self) -> NSTimeInterval
where Self: Sized + Message { ... }
unsafe fn sources(
&self,
) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>
where Self: Sized + Message { ... }
}GCPressedStateInput only.Expand description
An object conforming to
GCPressedStateInputrepresents the pressed state of
an element, typically a button.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn pressedDidChangeHandler(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>
Available on crate features GCPhysicalInputElement and block2 only.
unsafe fn pressedDidChangeHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>
GCPhysicalInputElement and block2 only.Set this block if you want to be notified when the pressed state changes.
§Safety
- The returned block’s argument 1 must be a valid pointer.
- The returned block’s argument 2 must be a valid pointer.
Sourceunsafe fn setPressedDidChangeHandler(
&self,
pressed_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>>,
)
Available on crate features GCPhysicalInputElement and block2 only.
unsafe fn setPressedDidChangeHandler( &self, pressed_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCPhysicalInputElement>>, NonNull<ProtocolObject<dyn GCPressedStateInput>>, Bool)>>, )
GCPhysicalInputElement and block2 only.Setter for pressedDidChangeHandler.
This is copied when set.
Sourceunsafe fn isPressed(&self) -> bool
unsafe fn isPressed(&self) -> bool
Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of interpreting the value.
As a general guideline a button is pressed if the value exceeds 0. However there may be hysteresis applied to counter noisy input values, thus incidental values around the threshold value may not trigger a change in pressed state.
Other buttons may support two-stage actuation, where the button reports a value between 0 and 1 but is only considered pressed when its value is greater than some threshold other than 0.
See: pressedDidChangeHandler
Sourceunsafe fn lastPressedStateTimestamp(&self) -> NSTimeInterval
unsafe fn lastPressedStateTimestamp(&self) -> NSTimeInterval
The timestamp of the last pressed state change.
This time interval is not relative to any specific point in time. You can subtract a previous timestamp from the current timestamp to determine the time (in seconds) between changes to the value.
Sourceunsafe fn lastPressedStateLatency(&self) -> NSTimeInterval
unsafe fn lastPressedStateLatency(&self) -> NSTimeInterval
The interval (in seconds) between the timestamp of the last pressed state change and the current time.
This should be treated as a lower bound of the event latency. It may not include (wired or wireless) transmission latency, or latency accrued on the device before the event was transmitted to the host.
Sourceunsafe fn sources(
&self,
) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>
Available on crate feature GCPhysicalInputSource only.
unsafe fn sources( &self, ) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>
GCPhysicalInputSource only.An object describing the physical action(s) the user performs to manipulate this input.