Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help running extension based on event

New Here ,
Nov 11, 2011 Nov 11, 2011

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

TOPICS
Extensions
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 14, 2011 Nov 14, 2011

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/WS5b3ccc516d4fbf351e63e3d117f53d7b3e-7ffd.html

In parcitualr the Floater API functions:

http://help.adobe.com/en_US/dreamweaver/cs/extend/WS5b3ccc516d4fbf351e63e3d117f53d7b3e-7ffc.html

Danilo Celic

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2011 Nov 14, 2011
LATEST

I will take a look at the Floating panels. By the way, I'm writing a tutorial later to show users how to collapse entire code blocks {..} with the click of one button without adding an extension. It is very simple and easy to do. More on that later.

Danilo, thanks for the assistance. Code Collapse tutorial on the way!

UPDATE 11/20/2011

Dreamweaver CS5 Code Folding

http://www.youtube.com/watch?v=KSx8o0HDTlM

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines