TE Edit Control Java / HTML-JavaScript Help
Product page

Teh Control Events

WebTeh control does not support any server-side events. However, WehTeh automatically generates a call to the ControlCreated function so as to provide an opportunity to perform further initialization. So your web page must include a Control Created function to catch this event. You would add code for further initialization and code to catch other events within this function. Here is an example:

<script>
   var tej=null;   // a global variable to hold the Tej control object
   function ControlCreated(WebTej)  // this gets called when the edit control is                                     // created and displayed
    {
         tej = WebTej;
         console.log("Page is loaded!");
        // Example of adding or removing toolbar icons
         tej.TerAddToolbarIcon(0,0,tc.ID_SUPSCR_ON,
                               "images/icon1.bmp","superscript"); 
          tej.TerAddToolbarIcon(0,0,tc.ID_SUBSCR_ON,
                                "images/icon2.bmp","subscript");
          tej.TerHideToolbarIcon(tc.TLB_HELP,true);  // remove this icon
          tej.TerRecreateToolbar(true);
          // Example of disabling a speedkey
          tej.TerEnableSpeedKey(tc.ID_CHAR_STYLE,0);  // disable the original
                                                      // Alt+1 key command
         // Catch other event
         tej1.TerSetEvent("Preprocess",PreprocessEvent);  // an example of
                                               // catching the preprocess event
         tej1.TerSetEvent("Hypertext",Hypertext);
     } 
</script>

In addition, you can catch all the events support by the Teh Control.

The embedded Teh control fires the regular events within the WebPage. A full description of the available event names and corresponding input parameter can be found in the Control Events topic.

Please see the example above to catch the Preprocess and Hypertext event. The first parameter specifies the name of the event to catch, and the second parameter specify the function to call. So, you would define two script function to resolve the references to the PreprocessEvent and Hypertext event. Example:

<script>
function PreprocessEvent(obj, ActionType, ActionId) { console.log("Preprocess, object id: ",obj.cvs.id,"type", ActionType,"id: ",ActionId); } function Hypertext(obj,HText,HCode) { if (HCode.indexOf("http://")==0) window.open(HCode); else if (HCode.indexOf("www.")==0) window.open("http://"+HCode); else alert("Hypertext: "+HText+"\nCode/url: "+HCode); } </script>

In the examples above, WebTej refers the 'canvas' hosting the Teh control.

Please refer to the included Default.aspx and terh.htm files for a complete example.