[squeak-dev] Question on the signals/slots mechanism in Morphic Designer

Marcel Taeumel marcel.taeumel at hpi.de
Wed Mar 28 06:39:13 UTC 2018


Hi Edwin,

try to user patterns to reorder arguments:

self
   connect: self ui cmbStations signal: #currentIndexChanged:text:
   to: self ui edtStationId selector: #theText:
   pattern: #(2). "Here: 1 is the index, 2 is the text, and 0 would be the sender."

Take a look at the documentation here:
https://github.com/hpi-swa/signals#arguments-and-patterns [https://github.com/hpi-swa/signals#arguments-and-patterns]

Best,
Marcel
Am 28.03.2018 00:49:06 schrieb Edwin Ancaer <eancaer at gmail.com>:
Hello,


I  struggle a bit to make my problem clear, so forgive me if I write too much text.

To better understand how to build User Interfaces in an Object Oriented environment, I did some searching on the internet. I stumbled upon an article of Martin Fowler on the different GUI architectures. To help me understand what I was reding, I tried to build the UI that was used as an example. I did this with Morphic Designer, and building the UI went fine.


Next, I had to write some methods, to get the UI displayed on the screen. Still no big problems.


But then I needed to add some logic to use the value that was selected in a combobox widget to edit a lineEdit widget.:  I connected its signal #currentIndexChanged:text: to the method  #fill that initializes a textbox edtStationId with the value that was selected from the combobox..

connecting the signal:

self connect:  self ui cmbStations signal: #currentIndexChanged:text:  toSelector: #fill.



the method #fill: 

self ui edtStationId theText: self ui cmbStations currentText.


This works, but it feels like cheating: I had hoped to be able to use the parameters from the signal to initialize the textfield, instead of having to reread this value explicitly with the currentText method from the comboBox. Also, I think this will only work when my fill method is defined in the same class where the comboBox is used.As I see how the interface should interact with the rest of the application, this should not be the case as it seems its better to decouple the UI from the application.


Is there a way to use the parameters of the signal directly instead of going back through the comboBox to get the selected values.

Hope that I was clear enough in my explications, and thanks already,


Edwin Ancaer.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20180328/9f427a44/attachment.html>


More information about the Squeak-dev mailing list