Hi,
I use tm_dialog dozens of times to simplify matters, and to save time ;) But sometimes I would need a bit more (like the accessory views ;) ):
I wonder if it would be possible to write a nib which contains a button, e.g. 'Browse', and if I press this button it opens an other nib (or in that case a file select dialog). The returned value from the called nib (file select) will set a value in the first nib?
An other approach:
Press a button in tm_dialog. In tm_dialog there is a buttonListener. If that button is set to invoke a shell script then do it. This shell script (an other tm_dialog or what ever) could write something to a file and its content could update my actual tm_dialog.
Would this be too complicated or even impossible to implement?
Up to now I did such things like
PLIST1 = "..." PLIST2 = "..." pressedButton = Browse while pressedButton == Browse pressedButton = $DIALOG -p PLIST1 a_nib if pressedButton == Browse PLIST2 = $DIALOG -p PLIST2 a_other_nib PLIST1 = modify with values of PLIST2 end while
Application examples could be: - a Browse button to open a separate File Select Dialog - a Edit button to edit preferences for the tm_dialog - a Install button to install stuff which is missing without leaving tm_dialog - a Refresh button to refresh values in the tm_dialog
Or is there an other way to do something like that?
Do I carry things too far? ;)
Cheers,
Hans
On 3. Aug 2007, at 13:32, Hans-Joerg Bibiko wrote:
[...] I wonder if it would be possible to write a nib which contains a button, e.g. 'Browse', and if I press this button it opens an other nib (or in that case a file select dialog). The returned value from the called nib (file select) will set a value in the first nib?
That should be possible.
If you open a nib asynchronously (-a) and bind a button action to returnArgument: or connect it to performButtonClick: then the button will make "$DIALOG" -w«token» return, but will not close the window or anything (using performButtonClick: you will get the label + tag for the button clicked in the resulting plist).
Then do your stuff and update first nib using "$DIALOG" -t«token» when you have the updated plist (model).
On 4 Aug 2007, at 06:23, Allan Odgaard wrote:
On 3. Aug 2007, at 13:32, Hans-Joerg Bibiko wrote:
[...] I wonder if it would be possible to write a nib which contains a button, e.g. 'Browse', and if I press this button it opens an other nib (or in that case a file select dialog). The returned value from the called nib (file select) will set a value in the first nib?
That should be possible.
If you open a nib asynchronously (-a) and bind a button action to returnArgument: or connect it to performButtonClick: then the button will make "$DIALOG" -w«token» return, but will not close the window or anything (using performButtonClick: you will get the label + tag for the button clicked in the resulting plist).
Simple example: I bound two buttons to performButtonClick: (in FirstResponder) and one button (Cancel) to performClose: (in NSWindow or NSPanel). If I invoke the nib via
"$DIALOG" -m the_nib
everything works fine. The result is e.g.: <dict> <key>returnButton</key> <string>Button1</string> <key>returnCode</key> <integer>1</integer> </dict> or <dict> <key>returnButton</key> <string>Button2</string> <key>returnCode</key> <integer>2</integer> </dict> If I invoke it via
"$DIALOG" -a the_nib
the dialog appears. Then I call (my token is 3)
"$DIALOG" -w 3
the dialog/TM hangs. The dialog (a panel) doesn't accept any event. I only can press APPLE+. to cancel. As a window it returns (async) Window 3: error 1
My goal is that if I press Button1 to call function1 and if I press Button2 to call Function2. If I press the Cancel button to call "$DIALOG" -x $mytoken.
What am I doing wrong?
Any hints?
Hans
On 6. Aug 2007, at 14:00, Hans-Joerg Bibiko wrote:
[...] If I invoke it via
"$DIALOG" -a the_nib
the dialog appears. Then I call (my token is 3)
"$DIALOG" -w 3
the dialog/TM hangs. The dialog (a panel) doesn't accept any event. I only can press APPLE+. to cancel. As a window it returns (async) Window 3: error 1
It hangs because -w will make "$DIALOG" stall until an action is performed in the window, but since you run it from TM, the main thread (in TM) will wait for your command to finish, and thus block the UI.
Try instead run it in a shell -- in practice you’d run it in a command that detaches.
On 06.08.2007, at 19:13, Allan Odgaard wrote:
On 6. Aug 2007, at 14:00, Hans-Joerg Bibiko wrote:
[...] If I invoke it via
"$DIALOG" -a the_nib
the dialog appears. Then I call (my token is 3)
"$DIALOG" -w 3
the dialog/TM hangs. The dialog (a panel) doesn't accept any event. I only can press APPLE+. to cancel. As a window it returns (async) Window 3: error 1
It hangs because -w will make "$DIALOG" stall until an action is performed in the window, but since you run it from TM, the main thread (in TM) will wait for your command to finish, and thus block the UI.
Try instead run it in a shell -- in practice you’d run it in a command that detaches.
Arrgh. Yes, of course. Many thanks.
Hans