Italian [abbandonato] B4J - bottom menu

ivanomonti

Expert
Licensed User
Longtime User
ciao ragazzi non ricordo se esiste in b4j un bottone con menu e non contextmenu, cioò al suo click appare il suo menu.
 

ivanomonti

Expert
Licensed User
Longtime User
No, non esistono tasti ("bottoni" non mi piace, li vedo bene solo su camicie, giacche, cappotti... ?) che abbiano un menu; tu stesso hai citato i context menu, per qualunque view.
ma non vorrei il tasto dx del mouse ma al click
 

Gianni M

Well-Known Member
Licensed User
Longtime User
non ho modo di controllare, ma il button ha tra i vari eventi la possibilità di conoscere il semplice click, un long click, sx, dx, .... o confondo con un'altro linguaggio ?
 

Gianni M

Well-Known Member
Licensed User
Longtime User
ok, ricordavo bene!
 

ivanomonti

Expert
Licensed User
Longtime User

in effetti serve solo per mostrare il menu, poi il menu ha il suo evento, anche perchè ho menu dinamici e devo mostrare voci al volo (fatto) vedi immagin e il tasto dx fa cagare


 

LucaMs

Expert
Licensed User
Longtime User
B4X:
Sub btnShowMenu_MousePressed (EventData As MouseEvent)
    If EventData.PrimaryButtonPressed Then
        Dim btn As Button = Sender
        Dim cm As ContextMenu = btn.ContextMenu
        Dim jo As JavaObject = cm
        jo.RunMethod("show", Array(btn, MainForm.WindowLeft + btn.Left + 20, _
         MainForm.WindowTop + btn.Top + 50))
    End If
End Sub

(volendo potresti modificarla per farla funzionare con una Label - o potrei adattarla per farla funzionare con entrambi i tipi di view)
 

LucaMs

Expert
Licensed User
Longtime User
Così, se ad una View che abbia il Context Menu, dai come nome evento "ShowMenu", funziona (qui previste solo Button e Label; eventualmente aggiungere "blocchi" Else If Nd Is xxx a seconda dal tipo di View).

B4X:
Sub ShowMenu_MousePressed (EventData As MouseEvent)
    ShowContextMenu(Sender)
End Sub


Sub ShowContextMenu(Nd As Object)
    Dim cm As ContextMenu
    Dim Nd2 As Node = Nd
   
    If Nd Is Button Then
        Dim btn As Button = Nd
        cm = btn.ContextMenu
    Else If Nd Is Label Then
        Dim lbl As Label = Nd
        cm = lbl.ContextMenu
    'Altre view che abbiano il context menu
    'Else If Nd is ??? Then
    End If

    Dim jo As JavaObject = cm
    jo.RunMethod("show", Array(Nd2, MainForm.WindowLeft + Nd2.Left + 20, _
         MainForm.WindowTop + Nd2.Top + 50))
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…