×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    10

    Question Handling "Back" Softkey Events

    Hi,

    I've searched high and low for this but can't find an answer...

    When a user presses the "back" key (i.e. the right softkey) to move back a screen in an application, how do I catch this?

    I know that when the right softkey displays "Exit" you can catch this with the handler...

    appuifw.app.exit_key_handler

    ...but can I handle the event when the right softkey does a "back" to a previous screen in a gui ?

    Thanks for any help,

    M.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    24
    try with this:
    appuifw.app.menu = []
    appuifw.app.menu.append((u"back",self.func))
    Where self.func is the function that handle the callback.
    bye

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    10
    Here's an example of what I mean.

    When you run the script below after the info message you are presented a single choice.

    The left softkey displays "OK" and chooses the option. The right softkey shows "Exit". Hitting exit at this point calls the exit_key_handler. So far so good.

    When the option is chosen a simple form is shown. The softkeys now read "Options" and "Back".

    What I'd like to do is trap the "Back" event, and make it call show_main_view again (i.e. display the info message again).

    Thanks again.

    M.

    Code:
    import e32
    import appuifw
    
    class Test:
        def __init__(self):
            self.lock = e32.Ao_lock()
            appuifw.app.exit_key_handler = self.abort
            self.exit_flag = False
            
        def show_main_view(self):
            appuifw.note(u"Hello", 'info')
            self.choice = [(u"Choice 1") ]
            self.lb = appuifw.Listbox(self.choice, self.callback)
            appuifw.app.body = self.lb
    
        def callback(self):
            self.fields = [(u"Text Field", 'text') ]
            self.form = appuifw.Form(self.fields, appuifw.FFormDoubleSpaced)
            self.form.execute()       
            
        def abort(self):
            self.exit_flag = True
            self.lock.signal()
    
        def run(self):
            while not self.exit_flag:
                self.show_main_view()
                self.lock.wait()
    
    if __name__ == "__main__":
        old_title = appuifw.app.title
        old_exit_key = appuifw.app.exit_key_handler
        try:
            appuifw.app.title = u"Test"
            e32.ao_yield()
            app = Test()
            app.run()
        finally:
            appuifw.app.set_tabs([], None)
            appuifw.app.exit_key_handler = old_exit_key
            appuifw.app.title = old_title

  4. #4
    Regular Contributor
    Join Date
    Dec 2004
    Location
    Czech Republic
    Posts
    50
    I am not sure what do you think, but you just need to do something when you leave the form.

    I would try this

    Code:
        def callback(self):
            self.fields = [(u"Text Field", 'text') ]
            self.form = appuifw.Form(self.fields, appuifw.FFormDoubleSpaced)
            self.form.execute()       
            # here insert  the code

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    10
    Thanks for the tip Zen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×