Class DropDownDeactivateGuard
java.lang.Object
com.iizigo.swt.DropDownDeactivateGuard
Decides whether a deactivation closes a drop-down shell that closes when it or its parent shell loses the activation, such as the drop-down of the
ColorSelectionWidget.On GTK the activation of a shell is asynchronous: the deactivation that the opening of a drop-down causes arrives through the event loop after open() returned (measured on STJERNA: the parent shell deactivated 77-148 ms after the drop-down was shown, and the drop-down closed by itself), where on Windows and macOS it arrives inside open(). On GTK, a deactivation that arrives within GTK_GRACE_MS of the opening, while the pointer or the focus is still on the widget or the drop-down, is that echo of the opening and is ignored. Any later deactivation, and every deactivation on every other platform, closes the drop-down as before.
CC-FIX-COLOR-DROPDOWN-GTK (FH-D-5, IIZI-GO-COLOR-DROPDOWN-CLOSES-ON-GTK).
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe time after the opening of a drop-down within which a deactivation on GTK may be the echo of the opening, in milliseconds.Constructor Summary
ConstructorsConstructorDescriptionDropDownDeactivateGuard(String platform, LongSupplier clock, BooleanSupplier isPointerOrFocusOnWidget) Constructs the guard of a platform with a clock.DropDownDeactivateGuard(BooleanSupplier isPointerOrFocusOnWidget) Constructs the guard of the running platform (SWT.getPlatform()) with the system clock.Method Summary
Modifier and TypeMethodDescriptionbooleanTells whether a deactivation that arrives now is ignored: true only on GTK, withinGTK_GRACE_MSof the last opening, while the pointer or the focus is on the widget or the drop-down.voidopened()Notes the opening of the drop-down: called just before its shell is opened.
Field Details
GTK_GRACE_MS
public static final long GTK_GRACE_MSThe time after the opening of a drop-down within which a deactivation on GTK may be the echo of the opening, in milliseconds.- See Also:
Constructor Details
DropDownDeactivateGuard
Constructs the guard of the running platform (SWT.getPlatform()) with the system clock.- Parameters:
isPointerOrFocusOnWidget- Tells whether the pointer or the focus is on the widget or its drop-down; asked only on GTK, within the grace time.
DropDownDeactivateGuard
public DropDownDeactivateGuard(String platform, LongSupplier clock, BooleanSupplier isPointerOrFocusOnWidget) Constructs the guard of a platform with a clock.- Parameters:
platform- The SWT platform, asSWT.getPlatform()names it ("gtk","win32","cocoa").clock- The clock, in milliseconds.isPointerOrFocusOnWidget- Tells whether the pointer or the focus is on the widget or its drop-down; asked only on GTK, within the grace time.
Method Details
opened
public void opened()Notes the opening of the drop-down: called just before its shell is opened.isIgnored
public boolean isIgnored()Tells whether a deactivation that arrives now is ignored: true only on GTK, withinGTK_GRACE_MSof the last opening, while the pointer or the focus is on the widget or the drop-down.- Returns:
- true to keep the drop-down open, false to close it as before.