B4J Tutorial Floating ContextMenu using jNativeHookB4j

ThRuST

Well-Known Member
Licensed User
Longtime User
Behold!! Here's 'Demostyle CSS theme' offical style template (v0.9) for Steves contextmenu and also for project Mindcraft I got a bit carried away as you can see.
Now people can start design their own style and either post here or email it to me directly. If it's good it will be included and part of the released beta version.
Designing this took alot of time but I wanted to tweak it to get it as good as possible. As you can see these designs are getting better and better.
I commented the CSS template to make it as easy as possible to make changes, it's really simple now so keep using this CSS template, you too Steve, please
Btw, I left a secret in this template.. unmark any one the -fx-shape under MenuItem Selector Color to see the hidden effects taken from the site Steve mentioned.
Please note: Markers color does not yet work.



CSS
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Very nice,

I've added it to v0.8.5
 

stevel05

Expert
Licensed User
Longtime User
For the markers try:

B4X:
.menu > .right-container > .arrow {
    -fx-background-color: Red;
}

.menu:focused > .right-container > .arrow {
    -fx-background-color: Pink;
}

I don't mean the colors, just a test to make it obvious
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Here's what it looks like on my Mac. The menuitem selections CSS is not showing when the menu is not in focus, which happens when I click on the main form. Then it's showing correctly. The contextmenu still works as it should even when it's not in focus. This can help to make corrections to this and I will test it once updated.

 

ThRuST

Well-Known Member
Licensed User
Longtime User
Since the CSS script uses font broadway it seems to use font Helvetica on Mac. So I guess the correct font need to be provided in the installation if possible.
Maybe this is possible, so that the menu can look as fancy on all computers
 

stevel05

Expert
Licensed User
Longtime User
To answer your second question first, to use it in CSS, I think you would have to load it in the CSS file If I remember correctly. And probably add the font file to your app's files folder. I don't know if the fonts are compatible, or if it would be allowed in the font's licence to load it on a Mac. You could put an alternate font in the CSS (I think you just spoecify two) in case one isn't available. If you can find one on the Mac that you like.

For your first question, have you used CSS with a javafx app on Mac before? Does it normally work as expected? There is nothing in the program that involves CSS (apart from adding the classes), so I would guess it's either a javafx/CSS issue on Mac, or just a Mac issue.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
I have now updated the CSS theme to v0.8.5 which you can find i post #62. Paste the CSS theme over the current version and replace v0.8.5.
We're kinda busy today I'll look up the CSS stuff on Mac. I'm not sure how it works on a Mac but it would be nice to see it look the same. Oh about the CSS updated theme, it now shows red and pink arrows, you left your mark in my theme hehe
 

ThRuST

Well-Known Member
Licensed User
Longtime User
What about the MARKERS!! Those markers, don't leave them out, they're important in case there's any use for them, who knows
 

stevel05

Expert
Licensed User
Longtime User
Oh do you mean the check marks on the checkmenuitem?
 

stevel05

Expert
Licensed User
Longtime User
This should be more in keeping:

B4X:
// -----------------------------------------------------------------
// CheckMenuItem marks
// -----------------------------------------------------------------
.check-menu-item:checked > .left-container > .check {
    -fx-background-color: LightGray;
}
//-fx-mark-color

.check-menu-item:focused:checked > .left-container > .check {
    -fx-background-color: Lime;
}
//-fx-focused-mark-color


// -----------------------------------------------------------------
// SubMenu Arrows
// -----------------------------------------------------------------

.menu > .right-container > .arrow {
    -fx-background-color: White;
}

.menu:focused > .right-container > .arrow {
    -fx-background-color: Lime;
}
 

stevel05

Expert
Licensed User
Longtime User
If you want to try the Aqua.css Download the Aquafx.jar from the site and copy it to your addl libs folder then create a new project and put this as Main:

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
    #AdditionalJar: aquafx-0.1
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)

    Dim AJO As JavaObject
    AJO.InitializeStatic("com.aquafx_project.AquaFx")
    AJO.RunMethod("style",Null)


    MainForm = Form1
    'MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
End Sub

Load a layout.

It looks a bit fuzzy on my PC, maybe better on a Mac.

 
Last edited:

stevel05

Expert
Licensed User
Longtime User
should I remove it?

Yes, remove it. It was just to remind myself what was there in the first place.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
I've update the CSS theme to v0.9, grab it it's time to update again
 

ThRuST

Well-Known Member
Licensed User
Longtime User
please add in a screendump in your post at #75. This is starting to look like a pocket novel. Harlequin gold series lol
 

stevel05

Expert
Licensed User
Longtime User
Done
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…