[fxruby-users] deleting children and then adding new ones

Lyle Johnson lyle at lylejohnson.name
Mon Dec 10 14:06:09 EST 2007

On 12/10/07, Ralph Douglass <ralph at grayskies.net> wrote:

> I'm working on the ui for a little video game.  On the left in a map of the
> game's galaxy, and on the right in a panel.  When a planet on the left in
> clicked on, I want the panel on the right to change to display information
> and options for that planet.  When a user clicks on a fleet of ships, I want
> it to change to display information and options for the fleet.
> Is there perhaps a better way to do this than destroying the contents of the
> frame on the right every time?

Is the information associated with a planet always the same set of
widgets, just with different values? If so, I'd just update the
widgets' values whenever the user clicks on a new planet, e.g.

    planet_button.connect(SEL_COMMAND) do
        planet_name_label.text = planet.name
        planet_size_label.text = planet.size

Now, I'm assuming that you're displaying completely different kinds of
information when the user clicks on a fleet of ships, so you'd need to
do something different in that case. One option would be to implement
the right-hand side information panel as a switcher (FXSwitcher), with
one page for "planet information", another page for "fleet
information", etc. See the shutter.rb example for an idea of how you
might do that.

Hope this helps,


More information about the fxruby-users mailing list