0 Replies Latest reply on Feb 19, 2012 4:55 PM by jaloren28

    How do I map keystrokes to a character format?

    jaloren28 Level 2

      I want to create a script that intercepts the keystrokes ctrl+b and ctrl+i and then replaces the character format override with either a bold or italic character format.

       

      I know I need to use the notification method which will intercept user actions before the user performs action.

       

      Notification(Constants.FA_Note_PreFunction,true);

       

      Then use the notify call back function to take some action based on the FCode in the iparam.

       

      //call the nofify method

       

      function Notify(note, object, sparam, iparam)

      {

      //stuff goes here

      }

       

      So I tried this but it didn't work.

       

      Notification(Constants.FA_Note_PreFunction,true);

       

      Notify(Constants.FA_Note_PostFunction, app.ActiveDoc, app.ActiveDoc.Name, FCodes.TXT_BOLD)

       

      function Notify(note, object, sparam, iparam)

      {

        if (iparam==FCodes.TXT_BOLD)

      {

          Alert ('Bold keystroke occurred')

      }

      }

       

      Any ideas on how to intercept the keystrokes and then execute some task within the notify function if the iparam is the bold or italic fcode? Also, once I am able to successfully call the notify function like I want, how would I cause a character format to be applied to the text instead of a character format override?