On 9/24/09 6:35 PM, in article C6E16C5A.77B8%dru@summitprojects.com, "Dru Kepple" dru@summitprojects.com wrote:
Here's some stripped down code that works:
TextMate::UI.dialog(:nib => nib, :parameters => {}, :center => true) do |dialog| dialog.parameters = {'username' => "moo"} dialog.wait_for_input do |params| puts params["username"] end end
But then I go to try and actually use something with my params hash, like putting it into a variable declared earlier:
username = "" TextMate::UI.dialog(:nib => nib, :parameters => {}, :center => true) do |dialog| dialog.parameters = {'username' => "moo"} dialog.wait_for_input do |params| username = params["username"] end end puts username
Read the docs. :) Okay, there aren't really docs, but there is a very helpful comment explaining how to use wait_for_input:
# wait for the user to press a button (with performButtonClick: or returnArguments: action) # or the close box. Returns a dictionary containing the return argument values. # If a block is given, wait_for_input will pass the return arguments to the block # in a continuous loop. The block must return true to continue the loop, false to break out of it.
So, you're blocking because that's what the block does. It's just doing what you told it to do. But for your purposes, you don't need a block. Just capture the result of the call. So, for example (using a built-in nib example):
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui" nib = "#{ENV['TM_SUPPORT_PATH']}/nibs/RequestString.nib" username = "" TextMate::UI.dialog(:nib => nib, :parameters => {}, :center => true) do |dialog| dialog.parameters = {'string' => "Matt"} username = dialog.wait_for_input end puts username["returnArgument"]
Hope that gives you enough to move forward... m.