How to enable capturing the events from the Java HTML Editor to the form in Oracle Forms?

This will enable the generation of the events from the Java HTML Editor to the form:

Declare
hArgs FBEAN.ARGLIST;
Begin
hArgs:=FBEAN.CREATE_ARGLIST;
FBEAN.ADD_ARG(hArgs,true);
FBean.Invoke('HTMLEDITOR_AREA',1, 'setEnableCustomEventDispatching',hArgs);
End;

This code will capture the events using the WHEN-CUSTOM-ITEM-EVENT trigger of the form:

Declare
EventName VarChar2(32000);
Begin
EventName := :SYSTEM.Custom_Item_Event;

-- the event name contains all the event data starting with the event type like
-- keyPressed==>all the event data - for this make sure the variable used is long enough
-- you can later parse the data and use it accordingly:
-- here we put all in a text area to display it easily:

:block3.TEXT_AREA :=:block3.TEXT_AREA|| 'Event name: ' || EventName;
End;

Current event names start with the following names:

mouseReleased
mousePressed
mouseExited
mouseEntered
mouseClicked
mouseMoved
mouseDragged
focusGained
focusLost
insertUpdate
changedUpdate
keyTyped
keyPressed
keyReleased

If you want only specific events to be delivered you can set an event mask using the following method:

public void setCustomEventDispatchingMask(String eventMask) -This method allows only specified events to be dispatched once they have been enabled through the setEnableCustomEventDispatching. As argument can be specified a comma separated list of event names which are allowed to be dispatched to the  WHEN-CUSTOM-ITEM-EVENT. Example list of event names is as follows: "mouseReleased,insertUpdate,keyTyped" etc. By default all events are enabled through setEnableCustomEventDispatching.

hArgs:=FBEAN.CREATE_ARGLIST;;
FBEAN.ADD_ARG(hArgs, 'mouseReleased,insertUpdate,keyTyped');
FBean.Invoke('HTMLEDITOR_AREA',1, 'setCustomEventDispatchingMask',hArgs);

The related methods for configuring the event dispatching are as follows:

public void setEnableCustomEventDispatching(boolean customEventsDispatchingEnabled) - this method allows to enable/disable dispatching of the events from the editor to the underlying form

public boolean isEnableCustomEventDispatching() 
- this method returns whether is enabled/disabled dispatching of the events from the editor to the underlying form

public void dispatchOracleFormsEvent(String name, Object event) - this method allows to dispatch events from the editor to the underlying form which will captured into the WHEN-CUSTOM-ITEM-EVENT trigger of the form.

public void setCustomEventDispatchingMask(String eventMask)
-This method allows only specified events to be dispatched once they have been enabled through the setEnableCustomEventDispatching. As argument can be specified a comma separated list of event names which are allowed to be dispatched to the  WHEN-CUSTOM-ITEM-EVENT. Example list of event names is as follows: "mouseReleased,insertUpdate,keyTyped" etc. By default all events are enabled through setEnableCustomEventDispatching.
 
public void resetCustomEventDispatchingMask() - will reset the dispatching event mask.

public void setEnableActionEventMaskForUIItems(String uiItemNames,boolean discardDefaultActions)- this method allows to be captured only specific action events from all UI elements such as toolbars and menus. discardDefaultActions specifies whether the default action for the UI element to be suppressed or not. This way you can implement easily your own handlers for all UI items of the editor by disabling the default functionality and implementing a new one.

public void addKeyToKeyEventMask(int keyCode, boolean shiftDown, boolean altDown, boolean ctrlDown, boolean metaDown, boolean altGraphDown) - If key is added to the key event mask only events generated from this key will be dispatched as custom events, others will be ignored . To reset the event mask use resetKeyEventMask method. keyCode is the code of the key on the keyboard. Example Enter is 13, Space bar is 32 etc.

public void resetKeyEventMask() -To reset the event mask use resetKeyEventMask method

So if you want to set key event mask for the F9, Shift+F9 and F10 you will need to do like this:

htmlEditor.addKeyToKeyEventMask(120, false,false, false, false, false);
htmlEditor.addKeyToKeyEventMask(120, true, false, false, false, false);
htmlEditor.addKeyToKeyEventMask(121, false, false, false, false, false);