[TxMt] Ruby, UI.dialog, and popup controls

Dru Kepple dru at summitprojects.com
Tue Jun 9 00:05:03 UTC 2009


I'm rather new to both Ruby and Interface Builder.  So what better thing to
do than to try to write a command in Ruby that uses TextMate::UI.dialog?
Please excuse the newbness of my question.  I also apologize for the length
of my post, but I tried to provide as many details as I could.

I've managed to get some basic nib goodness happening, in the form of text
fields both setting values on nib launch, and returning values on nib close.

But I'd like to implement a popup control in my nib, and am at a complete
loss for how to get the values both in and out.  It's really just a short
list of options, not even dynamically generated, but it's not working and I
can't find any form of reference or help on Google.

Here's what I've got.  Without worrying about the popup control, this works:

TextMate::UI.dialog(:nib => nib, :parameters => {}, :center => true) do
|dialog|
  dialog.parameters = {'package' => 'com.mypackage', 'activity' =>
"ActivityClass"}
  dialog.wait_for_input do |params|
    package     = params['package']
    activity    = params['activity']
    puts "package:     #{package}"
    puts "activity:    #{activity}"
  end
end

I tried setting up the nib with an Array Controller, and binding Content
Array for Multiple Selection to my parameters Object Controller, with the
Model Key Path set to the parameter name (buildTarget).

This at least didn't cause errors, which was a huge step forward for me, and
even appears to return back the the whole array of objects that I'm passing
in.

Then I figure I need to bind the popup to the array controller, and I've
tried Content, Content Object, Content Values...but I'm really just shooting
in the dark.

If anyone has idea, or could even provide a reference or a working sample of
what I'm trying to do, I would be very grateful.




More information about the textmate mailing list