Discussion:
Correct method of initialising dependent controls
Tim Burgess
2014-03-17 17:40:55 UTC
Permalink
Hi,

I've never got this clear in my head, so I'm very overdue asking this
question. Here's the scenario:

1 - I have a dialog constructor designed to allow editing of an existing
object which is being passed in as a parameter.
2 - The required layout of the dialog is dependent on some aspect of the
object being passed in. For example, I have a group of radio buttons that
indicate the "type" of the received object - obviously, it's easy to use
SetValue( true) on the correct radio button to indicate the "type" at
construction time.

3 - Using SetValue( true) as described above does not trigger the event
handler for the chosen radio button, so how do I best control the
enabled/visible properties of any other controls in the dialog that are
dependent on the detected "type"? Should I just send the message manually to
cause the event handler to trigger, or is this bad practise?

Any and all advice gratefully accepted.

Best wishes.
Tim Burgess
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Fulvio Senore
2014-03-17 18:18:59 UTC
Permalink
Post by Tim Burgess
Hi,
I've never got this clear in my head, so I'm very overdue asking this
1 - I have a dialog constructor designed to allow editing of an existing
object which is being passed in as a parameter.
2 - The required layout of the dialog is dependent on some aspect of the
object being passed in. For example, I have a group of radio buttons that
indicate the "type" of the received object - obviously, it's easy to use
SetValue( true) on the correct radio button to indicate the "type" at
construction time.
3 - Using SetValue( true) as described above does not trigger the event
handler for the chosen radio button, so how do I best control the
enabled/visible properties of any other controls in the dialog that are
dependent on the detected "type"? Should I just send the message manually to
cause the event handler to trigger, or is this bad practise?
Any and all advice gratefully accepted.
In this situation I add to the dialog a helper function that does the
actual work of making controls visible or hidden, than I simply call
that function from the event handler.
I also call the same function when the dialog is created.

BTW, this is a good solution for hiding and showing controls.
For enabling and disabling them it is simpler to use update UI events.

Fulvio Senore
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Tim Burgess
2014-03-17 22:08:38 UTC
Permalink
Thanks for this - it's the way I'm currently doing things, but wanted to
check that I wasn't missing a trick:)

Best wishes.
Tim Burgess

-----Original Message-----
From: wx-***@googlegroups.com [mailto:wx-***@googlegroups.com] On Behalf
Of Fulvio Senore
Sent: 17 March 2014 18:19
To: wx-***@googlegroups.com
Subject: Re: Correct method of initialising dependent controls
Post by Tim Burgess
Hi,
I've never got this clear in my head, so I'm very overdue asking this
1 - I have a dialog constructor designed to allow editing of an
existing object which is being passed in as a parameter.
2 - The required layout of the dialog is dependent on some aspect of
the object being passed in. For example, I have a group of radio
buttons that indicate the "type" of the received object - obviously,
it's easy to use SetValue( true) on the correct radio button to
indicate the "type" at construction time.
3 - Using SetValue( true) as described above does not trigger the
event handler for the chosen radio button, so how do I best control
the enabled/visible properties of any other controls in the dialog
that are dependent on the detected "type"? Should I just send the
message manually to cause the event handler to trigger, or is this bad
practise?
Post by Tim Burgess
Any and all advice gratefully accepted.
In this situation I add to the dialog a helper function that does the actual
work of making controls visible or hidden, than I simply call that function
from the event handler.
I also call the same function when the dialog is created.

BTW, this is a good solution for hiding and showing controls.
For enabling and disabling them it is simpler to use update UI events.

Fulvio Senore

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...