B4J Tutorial Floating ContextMenu using jNativeHookB4j

This is an example of using @Roycefer 's jNativeHook to monitor all mouse events, even outside of the current app. It uses a ContextMenu to replicate the right click functionality. Default behaviour is overridden by the jNativeHook library and returning false from the relevant event sub.

It uses a dummy form to enable the context menu to be placed anywhere on the screen.

It's not been comprehensively tested and I can't guarantee it will work on Mac or Linux, but would be interested to know if it does.

Get the jNativehook files from here: https://www.b4x.com/android/forum/threads/jnativehookb4j-for-intercepting-system-input-events.55826/

Hope you enjoy it.

V 0.2 Update for Mac - see post #3
V 0.6 implements Tags, css styling of menu, checkmenuitem, submenus and a menutitle
V 0.7 Close all menus correctly
V 0.8 Added :
  • Ignore clicks on window (allows window to operate normally)
  • Multiple Floating Menus (Only one can be active at a time)
This update contains breaking code, MainForm has to be passed to the NativeHook initialization.

No version increment update fixed menu resize issue.
Demo only update to V0.8
V0.8.5 Added
ThRuST's latest css styles
Pause and Restart Mouse Listener
cmenu.css.zip contains the latest css.file
Tags : B4j Native Hook Floating Context Menu
12
 

Attachments

  • FloatingContextMenu-0-7.zip
    7.1 KB · Views: 573
  • cmenu.css.zip
    1 KB · Views: 580
  • FloatingContextMenu-0-8-6.zip
    10.3 KB · Views: 628
  • Test - cmenu.css.zip
    1 KB · Views: 528
  • FCMTest1.zip
    10.3 KB · Views: 561
Last edited:

ThRuST

Well-Known Member
Licensed User
Longtime User
It's still the same. I have an idea if CSSutils might solve the problem. CSS styling from code. What do you think about that?

mac5.jpg
 

stevel05

Expert
Licensed User
Longtime User
I can't see that it would make any difference where the CSS is set.

Try FCMTest1.zip
 

ThRuST

Well-Known Member
Licensed User
Longtime User
It's lunchbreak, I'm hungry, fish and cucumber :) I'll be back in a moment
 
Top