//------------------------------------------------------------------------------------// FormAPI code. Add this to DCT between < script>...< /script>function init() { // we CAN optionally setFocus so that the activeX gets loaded from the beginning and // the messages we send later on (ExecCommand) have a better chance of getting executed // uncomment next line if you want that //IWDatacapture.getItem("/item/path/to/textarea").setFocus(); // Note that loading the ActiveX runs in the background... at this time, the following holds: // top._dcWin.eWebEditPro.instances[0].isEditor() == 0 (false) // top._dcWin.eWebEditPro.instances[0].editor == null setVFhtml();}function setVFhtml(){ var vfobj = top._dcWin.eWebEditPro.instances[0]; if ( vfobj.isEditor() ) { // Note: if no 'setFocus' was done before on the VF field, // then after some time, the isEditor will be true, but the ExecCommand will not actually execute // However, I found no direct way to detect when that happens (no exception thrown, no special return value) // Also vfobj.status == 'loaded' at this point // !But! it seems that we can test with the Toolbars() function // It would be logical to combine the following 'if' with the previous, but keeping it like this // for the educational value if (vfobj.editor.Toolbars() != null) { vfobj.editor.ExecCommand('cmdviewashtml', '', 0); // alert('Should be ok now!'); return; } else { // alert('Toolbars NULL, VFE not active, will reschedule'); } } setTimeout("setVFhtml()", 1000); //alert('rescheduled');}IWEventRegistry.addFormHandler("onFormInit", init);//------------------------------------------------------------------------------------
external-editor-inline="f"
The basic concept is to set a repeating 'task' that checks every 0,5 seconds whether the VisualFormat Editor is loaded...
Have you checked if your timeout worked once? VF Editor instance that you operate upon is instantiated by the handler of (undocumented) "onFormLoad" event. It happens right before onFormInit, (actually in Edit mode handler fires "onFormInit" upon completion).
IWEventRegistry.addFormHandler("onFormInit", init);function init() { if (parent.datacapture.isDatacaptureLoaded) { custom_init(); } else { setTimeout("init()", 500); }}function custom_init() { // Place your "real" Init here}