From a8be2e764a3b8e54ea4e6f712d3c70995577d40a Mon Sep 17 00:00:00 2001 From: surbhi Date: Wed, 5 Sep 2018 15:42:41 +0530 Subject: [PATCH] Implement new feature for back button for screen tracking back with keyboard event attach --- src/bitmessagekivy/main.kv | 11 ++++++++++- src/bitmessagekivy/mpybit.py | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index ea8936c5..1d86c133 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -54,7 +54,16 @@ BoxLayout: size_hint_x: 0.1 pos_hint: {'x': 0.8, 'y':0.4} on_press: app.say_exit() - + ActionBar: + size_hint_y: 0.4 + size_hint_x: 0.1 + pos_hint: {'x': 0.99, 'y':0.35} + background_color: (0,0,0,0) + ActionView: + use_separator: True + ActionPrevious: + with_previous: True + on_release: app.set_previous_screen() ScreenManager: id: scr_mngr diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 3f9b198b..b8d0a724 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -19,6 +19,7 @@ from bmconfigparser import BMConfigParser from helper_ackPayload import genAckPayload from addresses import decodeAddress, addBMIfNotPresent from helper_sql import sqlExecute +from kivy.core.window import Window statusIconColor = 'red' @@ -38,8 +39,19 @@ class NavigateApp(App, TextInput): main_widget = Builder.load_file( os.path.join(os.path.dirname(__file__), 'main.kv')) self.nav_drawer = Navigator() + Window.bind(on_keyboard=self._key_handler) return main_widget + def _key_handler(self, instance, key, *args): + if key is 27: + self.set_previous_screen() + return True + + def set_previous_screen(self): + if self.root.ids.scr_mngr.current != 'inbox': + self.root.ids.scr_mngr.transition.direction = 'left' + self.root.ids.scr_mngr.current = self.root.ids.scr_mngr.previous() + def getCurrentAccountData(self, text): """Get Current Address Account Data.""" state.association = text