Question on the signals/slots mechanism in Morphic Designer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on the signals/slots mechanism in Morphic Designer

Edwin Ancaer
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.



Reply | Threaded
Open this post in threaded view
|

Re: Question on the signals/slots mechanism in Morphic Designer

marcel.taeumel
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:

Best,
Marcel

Am 28.03.2018 00:49:06 schrieb Edwin Ancaer <[hidden email]>:

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.



Reply | Threaded
Open this post in threaded view
|

Re: Question on the signals/slots mechanism in Morphic Designer

Edwin Ancaer
Marcel, 

I missed that while looking for documentation, sorry.

But I think it is clear now how to connect and pass the variables.

Thanks again,

Edwin

Op wo 28 mrt. 2018 08:39 schreef Marcel Taeumel <[hidden email]>:
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:

Best,
Marcel

Am 28.03.2018 00:49:06 schrieb Edwin Ancaer <[hidden email]>:

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.