Class SwtRx


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

      Constructors 
      Constructor Description
      SwtRx()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static kotlinx.coroutines.flow.Flow<Event> addListener​(Widget widget, int... events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
      static kotlinx.coroutines.flow.Flow<Event> addListener​(Widget widget, java.util.Collection<java.lang.Integer> events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
      static kotlinx.coroutines.flow.Flow<Event> addListener​(Widget widget, java.util.stream.Stream<java.lang.Integer> events)
      Subscribes to the given widget and pipes the events to an Flow<Event>.
      static Chit chit​(ControlWrapper wrapper)
      Wraps the given ControlWrapper in an Chit.
      static Chit chit​(Widget guard)
      Wraps the given Widget in an Chit.
      static <T> RxBox<T> combo​(Combo combo, ImmutableList<T> values, java.util.function.Function<T,​java.lang.String> converter)
      Populates a Combo returns an `RxBox` which is bidirectionally bound to the given combo.
      static <T> void combo​(Combo combo, ImmutableList<T> values, java.util.function.Function<T,​java.lang.String> converter, RxBox<T> box)
      Populates a Combo and bidirectionally binds it to an `RxBox`.
      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.
      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.
      static RxBox<java.lang.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
      static RxBox<java.lang.String> textImmediate​(Text text)
      Returns an RxBox which contains the content of the text box.
      static RxBox<java.lang.Boolean> toggle​(Button btn)
      Returns an `RxBox` for the toggle state of the given button as an RxBox.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SwtRx

        public SwtRx()
    • Method Detail

      • 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,
                                                                      java.util.Collection<java.lang.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,
                                                                      java.util.stream.Stream<java.lang.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<java.lang.String> textImmediate​(Text text)
        Returns an RxBox which contains the content of the text box.
      • textConfirmed

        public static RxBox<java.lang.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<java.lang.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,
                                         java.util.function.Function<T,​java.lang.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,
                                     java.util.function.Function<T,​java.lang.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.