Class SwtRx

java.lang.Object
com.diffplug.common.swt.SwtRx

public class SwtRx extends Object
Utilities that convert SWT events into Rx-friendly Observables.
  • Constructor Details

    • SwtRx

      public SwtRx()
  • Method Details

    • addListener

      public static kotlinx.coroutines.flow.Flow<Event> addListener(Widget widget, int... events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
    • addListener

      public static kotlinx.coroutines.flow.Flow<Event> addListener(Widget widget, Collection<Integer> events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
    • addListener

      public static kotlinx.coroutines.flow.Flow<Event> addListener(Widget widget, Stream<Integer> events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
    • rightClickGlobal

      public static kotlinx.coroutines.flow.Flow<Point> rightClickGlobal(Control ctl)
      Returns an Flow<Point> of the right-click mouse-up on the given control, in global coordinates.
    • rightClickLocal

      public static kotlinx.coroutines.flow.Flow<Point> rightClickLocal(Control ctl)
      Returns an Flow<Point> of the right-click mouse-up on the given control, in local coordinates.
    • textImmediate

      public static RxBox<String> textImmediate(Text text)
      Returns an RxBox which contains the content of the text box.
    • textConfirmed

      public static RxBox<String> textConfirmed(Text text)
      Returns an RxBox which contains the content of the text box only when it has been confirmed by:
      • programmer setting the RxBox
      • user hitting enter
      • focus leaving the text
    • toggle

      public static RxBox<Boolean> toggle(Button btn)
      Returns an `RxBox` for the toggle state of the given button as an RxBox.

      Applicable to SWT.TOGGLE, SWT.CHECK, and SWT.RADIO.

    • combo

      public static <T> RxBox<T> combo(Combo combo, ImmutableList<T> values, Function<T,String> converter)
      Populates a Combo returns an `RxBox` which is bidirectionally bound to the given combo.
      Parameters:
      combo - The combo which is being bound.
      values - The values which the RxBox can take on. Must match combo.getItems().
      Returns:
      An `RxBox` which is bound bidirectionally to the given combo.
    • combo

      public static <T> void combo(Combo combo, ImmutableList<T> values, Function<T,String> converter, RxBox<T> box)
      Populates a Combo and bidirectionally binds it to an `RxBox`.
      Parameters:
      combo - The combo which is being bound.
      values - The values which the RxBox can take on.
      converter - A function for mapping values to strings.
      values - The values which the RxBox can take on.
    • chit

      public static Chit chit(com.diffplug.common.swt.ControlWrapper wrapper)
      Wraps the given ControlWrapper in an Chit.
    • chit

      public static Chit chit(Widget guard)
      Wraps the given Widget in an Chit.