Skip navigation
Currently Being Moderated

Need help running extension based on event

Nov 11, 2011 10:37 AM

Tags: #auto-close

Hello fellow developers!

 

I'm developing an auto-close extension for opening braces and quotes. The problem I am having is trying to activate the extension code when the user types the character recognized as an auto-closed character. What do I need to do to activate my extension when the user presses a specific key on their keyboard?

 

For those who don't know what auto-close is. Here is an example.

 

Example: When the user types the opening brace {, the extension code will activate and insert the closing brace }, and then finally it will position the cursor between { and }

 

Thanks for any assistance with this problem. I'm tired of having to manually close a code block!

 

Sincerely yours,

 

Joshua Hesseman

 
Replies
  • Currently Being Moderated
    Nov 14, 2011 9:11 AM   in reply to hessemanj2100

    Dreamweaver has keyboard shortcuts which theoretically could be used for something like this, however, Shift+[  (which is the { character) isn't a valid keyboard shortcut, as letter or number key shortcuts require a CTRL (CMD on Mac) as part of the combination. In CS5.5 Adboe added the auto-close for ' and " however, there is no Dreamweaver API call associated with that (at least none that is documented if it exists at all).

     

    You may be able to use the documentEdited function within the Floating panels to be able to accomplish this, but you'd have to be checking for every character typed in code and that will likely be processor intensive for such a small feature. In fact the Floating panel documentation suggest not using documentEdited unless you have too due to potential performance issues.

     

    See the Floating panels docs:

    http://help.adobe.com/en_US/dreamweaver/cs/extend/WS5b3ccc516d4fbf351e 63e3d117f53d7b3e-7ffd.html

    In parcitualr the Floater API functions:

    http://help.adobe.com/en_US/dreamweaver/cs/extend/WS5b3ccc516d4fbf351e 63e3d117f53d7b3e-7ffc.html

     

     

     

    Danilo Celic

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points