scened-app-scene-byte-input.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include "scened-app-scene-byte-input.h"
  2. void ScenedAppSceneByteInput::on_enter(ScenedApp* app, bool need_restore) {
  3. ByteInputVM* byte_input = app->view_controller;
  4. auto callback = cbc::obtain_connector(this, &ScenedAppSceneByteInput::result_callback);
  5. byte_input->set_result_callback(callback, NULL, app, data, 4);
  6. byte_input->set_header_text("Enter the key");
  7. app->view_controller.switch_to<ByteInputVM>();
  8. }
  9. bool ScenedAppSceneByteInput::on_event(ScenedApp* app, ScenedApp::Event* event) {
  10. bool consumed = false;
  11. if(event->type == ScenedApp::EventType::ByteEditResult) {
  12. app->scene_controller.switch_to_previous_scene();
  13. consumed = true;
  14. }
  15. return consumed;
  16. }
  17. void ScenedAppSceneByteInput::on_exit(ScenedApp* app) {
  18. app->view_controller.get<ByteInputVM>()->clean();
  19. }
  20. void ScenedAppSceneByteInput::result_callback(void* context) {
  21. ScenedApp* app = static_cast<ScenedApp*>(context);
  22. ScenedApp::Event event;
  23. event.type = ScenedApp::EventType::ByteEditResult;
  24. app->view_controller.send_event(&event);
  25. }