B4J Question How to make a menu vsible code?

desof

Well-Known Member
Licensed User
Longtime User
I have a hidden menu you want to show in a given situation
as follows:

B4X:
menuActualizacion.VISIBLE = True

B4X:
Parsing code.                          0.01
Compiling code.                        Error
Error compiling program.
Error description: Unknown member: visible
Occurred on line: 154
menuActualizacion.VISIBLE=True
Word: visible

But it gives me error!

As shown?
 

desof

Well-Known Member
Licensed User
Longtime User
Menu does not have a Visible method, is it a MenuBar you've created? Or are you looking for a context menu?

There is some info here : http://docs.oracle.com/javafx/2/api/javafx/scene/control/Menu.html

1.jpg


The update menu option to show or hide whichever is applicable
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can use the JavaObject to set the visibility of a Menu and it's MenuItems or a single MenuItem

B4X:
Dim JO As JavaObject = MTest
    JO.RunMethod("setVisible",Array As Object(False))

Small example attached if it helps.
 

Attachments

  • MT.zip
    1 KB · Views: 319
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
You can use the JavaObject to set the visibility of a Menu and it's MenuItems or a single MenuItem

B4X:
Dim JO As JavaObject = MTest
    JO.RunMethod("setVisible",Array As Object(False))

Small example attached if it helps.



GENIUS!

thank you very much! exacatamente that's what I wanted and I guess used to enabled true or False
 
Upvote 0

dilettante

Active Member
Licensed User
Longtime User
It is starting to feel like a project of any real scope is going to end up with tons of these indirect calls via JavaObjects.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It is starting to feel like a project of any real scope is going to end up with tons of these indirect calls via JavaObjects.

B4J is still young, these things are bound to arise.

Hopefully, with these types of questions and posted solutions, it will make Erel's job easier to see what functions people are using, and use the solutions as a hint as to what needs to be implemented in the base Libraries.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4J is still young, these things are bound to arise.

Hopefully, with these types of questions and posted solutions, it will make Erel's job easier to see what functions people are using, and use the solutions as a hint as to what needs to be implemented in the base Libraries.
This is correct.

There is also no harm in using JavaObject. Especially for such "simple properties".
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
You can capture the clik Menu as this has no submenu (MenuIten)

(I think this has to do with this thread.
If not please tell me and put it in a new post)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I have looked at this in the past, although Menu inherits onAction from MenuItem, it appears that the onAction event doesn't fire. There are discussions about it on the internet, with some possible solutions, which I couldn't get to work elegantly. So I just used a sub menu.
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
I have looked at this in the past, although Menu inherits onAction from MenuItem, it appears that the onAction event doesn't fire. There are discussions about it on the internet, with some possible solutions, which I couldn't get to work elegantly. So I just used a sub menu.


ok!!! Tk
 
Upvote 0

dilettante

Active Member
Licensed User
Longtime User
Hopefully, with these types of questions and posted solutions, it will make Erel's job easier to see what functions people are using, and use the solutions as a hint as to what needs to be implemented in the base Libraries.

That's a more than fair response.

I keep forgetting that B4J: (1.) is still very new, (2.) not backed by a cash- and manpower-rich giant company, (3.) works pretty well even in its current state, (4.) one of few alternatives for writing JVM code in Basic, and of course (5.) free.
 
Upvote 0
Top