0

How to make Event handler for OptionsMenuItem in fullscreenwrapper2 and sl4a?

    FullScreenWrapper2App.get_android_instance().addOptionsMenuItem("Exit","exit",None,"ic_menu_revert") # adding exit options successfully, but how to make event handler of this?
    self.views.exit.add_event(click_EventHandler(self.views.exit, self.close_out)) #this is works, trigger close_out function when clicked.
    self.views.but_exit.add_event(click_EventHandler("exit", self.close_out)) # and this is too! this is works, trigger close_out function when clicked.

anyone can make it sweat?

Yuda Prawira
  • 12,075
  • 10
  • 46
  • 54

1 Answers1

0

solved my own problem. using add_event(EventHandler()) as a handler of OptionsMenuItem themself.

class MainScreen(Layout):
    def __init__(self):
        #initialize your class data attributes
        #load & set your xml
        super(MainScreen,self).__init__(pathhelpers.read_layout_xml("main.xml"),"Some title")

    def on_show(self):
    FullScreenWrapper2App.get_android_instance().addOptionsMenuItem("Exit",'exit','exit',"ic_menu_revert")
    self.add_event(EventHandler("exit", None, None, None, self.close_out))
Yuda Prawira
  • 12,075
  • 10
  • 46
  • 54