• Event bubbling

    From Joe Betz@21:1/5 to All on Sun Oct 31 21:53:01 2021
    Does Dolphin have any mechanisms for bubbling up mouse events?

    For example, I have a MessagePresenter which has a ContainerView which has a StaticText for the author name and another StaticText for the message content. I'd like for MessagePresenters to be able to handle all mouse events from all its subviews, but as
    is getting swallowed by the subviews.

    I think there should be a flag in View objects for controlling whether events are bubbled up to their parents. Or perhaps there are existing mechanisms I haven't discovered yet?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From vinref@gmail.com@21:1/5 to joeb...@gmail.com on Mon Nov 1 04:11:07 2021
    On Monday, 1 November 2021 at 14:53:02 UTC+10, joeb...@gmail.com wrote:
    Does Dolphin have any mechanisms for bubbling up mouse events?

    For example, I have a MessagePresenter which has a ContainerView which has a StaticText for the author name and another StaticText for the message content. I'd like for MessagePresenters to be able to handle all mouse events from all its subviews, but
    as is getting swallowed by the subviews.

    I think there should be a flag in View objects for controlling whether events are bubbled up to their parents. Or perhaps there are existing mechanisms I haven't discovered yet?

    Maybe you should look at #createSchematicWiring. With this you can 'listen' to events on an object you hold a reference to, such as a child component in a composite presenter. There are examples and explanations on its use in the Helpfile example (
    Tutorials > Creating a GUI Application).

    Vince

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From john.aspinall@gmail.com@21:1/5 to joeb...@gmail.com on Mon Nov 1 04:08:22 2021
    I'm not aware of a mechanism for this other than configuring subviews to bubble up individual events of interest. For example (modifying the FlowLayout example from the other thread):

    (shell := View desktop addSubView: ShellView new)
    backcolor: Color face3d;
    layoutManager: (layout := FlowLayout new);
    extent: 300 @ 200.
    shell insets: (10 @ 10 corner: 10 @ 10).
    layout
    verticalGap: 10;
    horizontalGap: SmallInteger maximum. "Force one item per row"
    entireArea := FramingConstraints new rightFraming: #fixedParentRight; bottomFraming: #fixedParentBottom.
    1 to: 10 do:
    [ :index || messageView label |
    (messageView := shell addSubView: ContainerView new)
    extent: 100@20;
    layoutManager: FramingLayout new;
    addSubView: (label := StaticText new).
    label
    arrangement: entireArea;
    text: 'Label <1d>' << index;
    when: #leftButtonPressed: send: #onLeftButtonPressed: to: messageView.
    messageView
    arrangement: entireArea;
    when: #leftButtonPressed: send: #inspect to: messageView].
    shell show.

    Older versions of Dolphin included a View subclass named Shield which was used by the View Composer to detect mouse events in the composition area - class comment:

    "Shield is a covering <view> that the View Composer uses to overlay its arena in order to capture appropriate mouse down events before they reach the windows in the underlying view being composed. The intercepted events are relayed to the Shield's target
    which, normally, will be a <ViewComposer>."

    Shield doesn't exist in current Dolphin versions, however since you don't need the "events are relayed to the Shield's target" function you can implement a minimal version with a class and two methods as follows:

    View subclass: #Shield
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    classInstanceVariableNames: ''


    defaultWindowExStyle
    "Private - Answer the default extended window creation style"

    ^super defaultWindowExStyle bitOr: WS_EX_TRANSPARENT


    onEraseRequired: aColorEvent
    "Private - Handler for erase background"

    ^true

    You can then use this to capture all mouse events before they reach other subview(s). To demonstrate replace the loop block in the above example:

    [ :index || messageView label shield |
    (messageView := shell addSubView: ContainerView new)
    extent: 100@20;
    layoutManager: FramingLayout new;
    addSubView: (shield := Shield new);
    addSubView: (label := StaticText new).
    label
    arrangement: entireArea;
    text: 'Label <1d>' << index.
    shield
    arrangement: entireArea;
    when: #leftButtonPressed: send: #inspect to: shield;
    when: #rightButtonPressed: send: #inspect to: label;
    when: #leftButtonDoubleClicked: send: #inspect to: messageView].

    Hope this helps.

    John


    On Monday, November 1, 2021 at 4:53:02 AM UTC, joeb...@gmail.com wrote:
    Does Dolphin have any mechanisms for bubbling up mouse events?

    For example, I have a MessagePresenter which has a ContainerView which has a StaticText for the author name and another StaticText for the message content. I'd like for MessagePresenters to be able to handle all mouse events from all its subviews, but
    as is getting swallowed by the subviews.

    I think there should be a flag in View objects for controlling whether events are bubbled up to their parents. Or perhaps there are existing mechanisms I haven't discovered yet?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joe Betz@21:1/5 to All on Fri Nov 5 01:09:50 2021
    Hope this helps.

    Yup, that helped. :)

    Maybe you should look at #createSchematicWiring. With this you can 'listen' to events on an object you hold a reference to, such as a child component in a composite presenter. There are examples and explanations on its use in the Helpfile example (
    Tutorials > Creating a GUI Application).

    Makes sense. I had looked at the GUI tutorial but was missing examples of low level key and mouse events though. Good to know they're already being emitted from Dolphin view objects.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)