public void postInputEvent(final String name, Dispatch2 params) throws TJSException { // posts input event if (mForm == null) return; final String key_name = "key"; final String shift_name = "shift"; // check input event name int type; if ("onKeyDown".equals(name)) type = etOnKeyDown; else if ("onKeyUp".equals(name)) type = etOnKeyUp; else if ("onKeyPress".equals(name)) type = etOnKeyPress; else type = etUnknown; if (type == etUnknown) Message.throwExceptionMessage(Message.SpecifiedEventNameIsUnknown, name); if (type == etOnKeyDown || type == etOnKeyUp) { // this needs params, "key" and "shift" if (params == null) Message.throwExceptionMessage(Message.SpecifiedEventNeedsParameter, name); int key = 0; int shift = 0; Variant val = new Variant(); int hr = params.propGet(0, key_name, val, params); if (hr >= 0) key = val.asInteger(); else Message.throwExceptionMessage(Message.SpecifiedEventNeedsParameter2, name, "key"); hr = params.propGet(0, shift_name, val, params); if (hr >= 0) shift = val.asInteger(); else Message.throwExceptionMessage(Message.SpecifiedEventNeedsParameter2, name, "shift"); char vcl_key = (char) key; if (type == etOnKeyDown) mForm.internalKeyDown(key, shift); else if (type == etOnKeyUp) mForm.onKeyUp(vcl_key, shift); } else if (type == etOnKeyPress) { // this needs param, "key" if (params == null) Message.throwExceptionMessage(Message.SpecifiedEventNeedsParameter, name); int key = 0; Variant val = new Variant(); int hr = params.propGet(0, key_name, val, params); if (hr >= 0) key = val.asInteger(); else Message.throwExceptionMessage(Message.SpecifiedEventNeedsParameter2, name, "key"); char vcl_key = (char) key; mForm.onKeyPress(vcl_key); } }
public void invalidate() throws VariantException, TJSException { // remove from list TVP.WindowList.unregisterWindowToList((WindowNI) this); // remove all events TVP.EventManager.cancelSourceEvents(mOwner.get()); TVP.EventManager.cancelInputEvents(this); // clear all window update events TVP.EventManager.removeWindowUpdate(this); // free DrawBuffer // if( mDrawBuffer != null ) mDrawBuffer = null; // disconnect all VideoOverlay objects try { mVideoOverlay.safeLock(); int count = mVideoOverlay.getSafeLockedObjectCount(); for (int i = 0; i < count; i++) { VideoOverlayNI item = mVideoOverlay.getSafeLockedObjectAt(i); if (item == null) continue; item.disconnect(); } } finally { mVideoOverlay.safeUnlock(); } // invalidate all registered objects mObjectVectorLocked = true; final int count = mObjectVector.size(); for (int i = 0; i < count; i++) { // invalidate each -- // objects may throw an exception while invalidating, // but here we cannot care for them. VariantClosure clo = mObjectVector.get(i); try { clo.invalidate(0, null, null); clo = null; } catch (TJSException e) { DebugClass.addLog(e.getMessage()); // just in case, log the error } } // invalidate menu object if (mMenuItemObject != null) { mMenuItemObject.invalidate(0, null, mMenuItemObject); mMenuItemObject = null; } // remove all events (again) // TVPCancelSourceEvents( mOwner ); // TVPCancelInputEvents( this ); // clear all window update events (again) // TVPRemoveWindowUpdate( this ); // release draw device // setDrawDeviceObject( new Variant() ); super.invalidate(); /* NOTE: at this point, Owner is still non-null. Caller must ensure that the Owner being null at the end of the invalidate chain. */ if (mForm != null) { mForm.invalidateClose(); mForm = null; } // remove all events TVP.EventManager.cancelSourceEvents(mOwner.get()); TVP.EventManager.cancelInputEvents(this); // Set Owner null mOwner.clear(); }