I want to add a context menu just on button of pane loaded.
Because when i add a context menu on my tabPane the menu can be open evrywhere...
where can i put my json for this context menu ?
And in my code i want to put multi tabPane based on a same layout. But if i do that, all my tabPane have the same name, i can't select just one. Just the last creat is used.
I try to make a map with here. Is it a good solution ?
B4X:
Sub nouvelleMatiere
Main.TabPaneMatiere.LoadLayout("FormMatiere","Nouvelle matiere")
mapMatiere.Put(nbMatiere+1,Main.TabPaneChapitre)
End Sub
Sub nbMatiere
Dim i As Int
If mapMatiere.IsInitialized=False Then
mapMatiere.Initialize
End If
i = mapMatiere.Size
Log("il y a : " & i & " matières")
Return i
End Sub
it's okay for my second probleme I find a solution :
I just use sub with indexselected :
B4X:
Sub MatiereSelectionne As TabPane
Dim l As List = Main.TabPaneMatiere.Tabs
Dim num As Byte = Main.TabPaneMatiere.SelectedIndex
Dim t As TabPage = l.Get(num)
Dim tt As TabPane = t.Content.GetNode(0)
Return tt
End Sub
But i don't find for the json context menu on button tab header...
Is it possible to put modif touch for shortcut key like this ?
1. Add an EventFilter.
2. Check the target parents and see whether the header is a parent.
3. Consume the event if not.
B4X:
Dim r As Reflector
r.Target = TabPane1
r.AddEventFilter("TabPane1", "javafx.scene.input.ContextMenuEvent.CONTEXT_MENU_REQUESTED")
Sub TabPane1_Filter (EventData As Event)
Dim ContextMenuEvent As JavaObject = EventData
Dim Target As JavaObject = ContextMenuEvent.RunMethod("getTarget", Null)
If Target Is Node Then
Dim n As Node = Target
Do While n.IsInitialized
If GetType(n) = "javafx.scene.control.skin.TabPaneSkin$TabHeaderSkin" Then Return
n = n.Parent
Loop
End If
EventData.Consume
End Sub