New Dialog System for Commands

Included with the latest build of TextMate (r1305) is a new system for presenting dialogs. The new system allows you to create a custom interface in Interface Builder and then ask TextMate to present it as was it native. This is without writing any code at all.

I have recorded a screencast which introduces the system and shows basic usage.

The screencast is part one of what I plan to be a four or five part series with the upcoming screencasts covering the following topics:

  • Using buttons in the dialog (for actions)
  • Handling selections in lists and outlines
  • Showing progress visually
  • Putting it all together

Update (2007-03-15): After this screencast was recorded, a change was made: the tm_dialog binary has been moved from Support/bin to be within the Dialog.tmPlugIn package. That way, the version of the shell command should always match that of the installed plug-in (i.e. if you install a newer version of the plug-in). To get the exact path of the tm_dialog shell command, in TextMate type: echo "$DIALOG" and press ⌃R (to execute that line). In your scripts, you should always access tm_dialog as just "$DIALOG" (that would be ENV['DIALOG'] for Ruby).

Another common troubleshooting item is running: "$DIALOG" «nib» and then not see a window. If you do not specify -p/--parameters then tm_dialog will read parameters from the standard input. So either press ⌃D to “close” stdin, or give -p '{}' as argument, and things should work as expected.

37 Comments

  1. 28 Oct 2006 | # Haris Skiadas wrote…

    Absolutely unbelievable! I find it hard to express myself right now, my mind is filled with possibilities. I foresee a lot of work ahead of me, in the various bundles I'm working on. :)

    Looking forward to the other screencasts.

  2. 28 Oct 2006 | # Jay Soffian wrote…

    Allan, very, very clever.

    j.

  3. 28 Oct 2006 | # Jay Soffian wrote…

    BTW, the movie seems to end kind of suddenly. Was it truncated by accident?

  4. 28 Oct 2006 | # Simon wrote…

    Fantastic! The possibilities are endless.

  5. 28 Oct 2006 | # Florian wrote…

    Very nice!

    It does end abruptly, though, as Jay mentioned.

  6. 28 Oct 2006 | # oliver wrote…

    I'd love to see the rest, looks very promising. I can't wait to see the rest of it.

  7. 28 Oct 2006 | # Ned Baldessin wrote…

    Briliant! Bravo!

  8. 28 Oct 2006 | # Axman6 wrote…

    Wow man, you have way to much skill. i was watching and i was just amazed, this stuff is just to easy once you get it. i have to give it a try sometime.

    Anyway, thanks Allan, you're just awesome incarnate

    Al.

  9. 28 Oct 2006 | # pablo wrote…

    It's simply amazing… Allan, you're a genius !

  10. 28 Oct 2006 | # James Andrews wrote…

    Just had to echo the comments here: Pure Genius.

    Watching this put a great big smile on my face. :) <- there it is!

  11. 28 Oct 2006 | # Chriztian Steinmeier wrote…

    It's always a sublime treat to watch your screencasts – the "moneyshot" in this one is where you miss-spell "cruel" by writing "curel", and instead of doing what every other creature on this planet would have done (delete and rewrite) you actually pull out the "Transpose" command which swaps 'u' & 'r' – monster chops, ha! :-)

  12. 29 Oct 2006 | # keith wrote…

    It's stuff like this that highlights the genius of Allan.

    Totally awesome.

  13. 29 Oct 2006 | # fred wrote…

    Fantastic, Allan. This is amazing stuff!

  14. 30 Oct 2006 | # Michael Ströck wrote…

    Very nice stuff. Speaks volumes about your skills and the power of the environment OS X developers work in.

    Imagine doing this without a UNIX shell with pipes and STDIN/STDOUT, meaningful support for high-level languages like Ruby/Python, Cocoa, Cocoa Bindings and Key-Value-Coding, Interface Builder, etc…

  15. 30 Oct 2006 | # stet wrote…

    My god! It's like MPW is reborn. Genius, dude.

  16. 30 Oct 2006 | # Ian wrote…

    i really loved this demonstration. we learn about your fantastic application and you teach us about bindings and some functionality of interface builder I have so far missed [ the make sub-views stuff ] Very very cool. Thanks

  17. 30 Oct 2006 | # Ben wrote…

    Loved the halloween additions to the newest rev… very fun. For a moment I thought that – gasp – I had some kind of weird virus that was – gasp – asking me if I, if I – oh… wanted to review my documents for unsaved changes before I quit… Sweet, new TM.

  18. 30 Oct 2006 | # paul wrote…

    i love the halloweener updates, those are slick!

  19. 31 Oct 2006 | # Joe User wrote…

    The icon made my day. I bought TextMate on the spot because of it. This sounds insane, but man, it's the little things for me. More silly easter eggs to make a programmer's life more interesting, please!

  20. 31 Oct 2006 | # Chad wrote…

    Any chance of posting the nib you generated during the demo?

  21. 31 Oct 2006 | # Mike Ter Louw wrote…

    Great pumpkin icon, Allan! Thanks. :)

  22. 31 Oct 2006 | # Jamie Wilkinson wrote…

    Happy Halloween! Late night coding surprise :)

  23. 31 Oct 2006 | # ad wrote…

    That was cool! So cool, that i made a blogentry about the TextMate Halloween Editon! Happy Halloween and thanks for that great editor!

  24. 31 Oct 2006 | # Devon wrote…

    I enjoyed the Halloween surprise. Programming TextMate is obviously fun for you!

  25. 31 Oct 2006 | # Brendon wrote…

    About the Halloween icon. It is so much cooler than the proper Textmate icon, that I don't want to you revert back to the old one. I design user-interfaces and I can tell you that there is something about that icon that makes me want to use Textmate more that I do already.

    Don't you dare remove it!

  26. 31 Oct 2006 | # Nathan wrote…

    If anyone wants it, I pull it out of the package: TextMate.icns

  27. 31 Oct 2006 | # John wrote…

    Thanks alot! I've just built a build selection dialog for selecting ant targets and it works just great. So now I don't really need to change the build.xml default build or build from the commandline anymore. Thank you!

  28. 01 Nov 2006 | # Alex wrote…

    I might be missing the point, but is the idea to create custom dialogs to use only within TextMate? Or to be able to roll out scripts that present nib based dialogs on their own (without TextMate present)?

  29. 01 Nov 2006 | # John wrote…

    Alex. The idea is to use scripts to set up a dialog interface and receive a return value. The nibs load into TextMate which makes the dialogs part of TextMate. As I wrote above, I just wrote some scripts, xsl and created a nib so that I can choose the ant target I wish to run from a standard cocoa dropdown. This integrates ant into TextMate even further while still keeping the flexibility of TextMate.

  30. 01 Nov 2006 | # Sebastian Gräßl wrote…

    Wow! i thought CocoaDialog is a powerfull way for doing simple dialogs in Bundles but this is just WOW. i think i'll have to remake the Get Bundle

  31. 04 Nov 2006 | # Stefan wrote…

    Great Tool!! When can we expect more information on the usage of tm_dialog? Is there some kind of documentation available? Thanks!

  32. 06 Nov 2006 | # Allan Odgaard wrote…

    Stefan: This letter mentions how to hook up buttons.

    There isn’t much specific to say about tm_dialog since most is related to how Interface Builder and bindings work.

    But I will do new screencasts with some common tasks when time permits. I probably will also write up a page or two with technical details, again, when time permits.

  33. 10 Nov 2006 | # Stefan wrote…

    Allan: Thank you for your hint.

    It took some time to figure out that the method has to be named "performButtonClick" in order to close the dialog window. I think the following post might be helpful: http://www.mail-archive.com/textmate-dev@lists.macromates.com/msg00840.html

  34. 09 Apr 2009 | # matthew wrote…

    Any chance there is an updated example available that shows how to do this (using "$DIALOG" now), within a shell script or terminal?

    Just a basic example of setting default values and getting user input from UI files built with Interface Builder would be really helpful. There is very little documentation available now that everything has been updated.

  35. 09 Apr 2009 | # Allan Odgaard wrote…

    matthew: If you have a svn checkout:

    cd /Library/Application\ Support/TextMate/Bundles
    find . -name .svn -prune -or -name \*.tmCommand -exec grep -sq DIALOG {} \; -print
    

    There should be at least a dozen default bundles which use $DIALOG. None of them are using v2 (yet), but v1 is not going anywhere.

  36. 10 Apr 2009 | # matthew wrote…

    Thanks for the response Allan, i am combing through the examples and trying to make sense of them.

    Trying to find a modern example of exactly what you showed in the first half of the screencast. Using Interface builder to get some input from the user.

  37. 08 Jun 2009 | # Fernando wrote…

    This is not working for me.

Comments closed, you can use the mailing list for discussion.