Interface MenuModel.ItemsChangedCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
MenuModel
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ItemsChangedCallback callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidrun(int position, int removed, int added) Emitted when a change has occurred to the menu.default MemorySegmenttoCallback(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, int, int, int)method.default voidupcall(MemorySegment sourceMenuModel, int position, int removed, int added) Theupcallmethod is called from native code.
-
Method Details
-
run
void run(int position, int removed, int added) Emitted when a change has occurred to the menu.The only changes that can occur to a menu is that items are removed or added. Items may not change (except by being removed and added back in the same location). This signal is capable of describing both of those changes (at the same time).
The signal means that starting at the index
position,removeditems were removed andaddeditems were added in their place. Ifremovedis zero then only items were added. Ifaddedis zero then only items were removed.As an example, if the menu contains items a, b, c, d (in that order) and the signal (2, 1, 3) occurs then the new composition of the menu will be a, b, _, _, _, d (with each _ representing some new item).
Signal handlers may query the model (particularly the added items) and expect to see the results of the modification that is being reported. The signal is emitted after the modification.
-
upcall
Theupcallmethod is called from native code. The parameters are marshaled andrun(int, int, int)is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, int, int, int)method.- Specified by:
toCallbackin interfaceFunctionPointer- Parameters:
arena- the arena in which the function pointer is allocated- Returns:
- the native function pointer
-