Closing a System Browser with Mouse Events - LucPrestin/Hidden-Modularity GitHub Wiki

Description

This scenario is the reverse of Opening-a-System-Browser-via-Workspace. We now want to close it after "using" it with a mouse click.

To do this, we first create a SystemBrowser to then get the close button in the window. On this we then simulate a click event by sending the events redMouseDownAt: and redMouseUpAt: one after the other.

Code


| browser button hand |

hand := HandMorph new.
browser := SystemBrowser defaultOpenBrowser.
button := browser containingWindow labelArea submorphs first.
	
^ TDBCursor traceForBlock: [
    button handleEvent: ((UserInputEventTests new redMouseDownAt: button center) setHand: hand).
    button handleEvent: ((UserInputEventTests new redMouseUpAt: button center) setHand: hand)
]

Hypotheses

Evaluation

Further insights (optionally)