[escher] InputEventHandler gets the app directly

This commit is contained in:
Ruben Dashyan
2019-06-06 14:04:47 +02:00
committed by EmilieNumworks
parent bcf2fda882
commit e4ec398ecd
5 changed files with 7 additions and 10 deletions

View File

@@ -1,17 +1,16 @@
#ifndef ESCHER_INPUT_EVENT_HANDLER_H
#define ESCHER_INPUT_EVENT_HANDLER_H
#include <ion.h>
#include <ion/events.h>
class InputEventHandlerDelegate;
class App;
class InputEventHandler {
public:
InputEventHandler(InputEventHandlerDelegate * inputEventHandlerdelegate) : m_inputEventHandlerDelegate(inputEventHandlerdelegate) {}
virtual bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) { return false; }
protected:
bool handleBoxEvent(App * app, Ion::Events::Event event);
bool handleBoxEvent(Ion::Events::Event event);
InputEventHandlerDelegate * m_inputEventHandlerDelegate;
};

View File

@@ -4,7 +4,7 @@
#include <escher/toolbox.h>
#include <escher/metric.h>
bool InputEventHandler::handleBoxEvent(App * app, Ion::Events::Event event) {
bool InputEventHandler::handleBoxEvent(Ion::Events::Event event) {
NestedMenuController * box = nullptr;
if (m_inputEventHandlerDelegate) {
box = event == Ion::Events::Toolbox ? m_inputEventHandlerDelegate->toolboxForInputEventHandler(this) : box;
@@ -12,7 +12,7 @@ bool InputEventHandler::handleBoxEvent(App * app, Ion::Events::Event event) {
}
if (box) {
box->setSender(this);
app->displayModalViewController(box, 0.f, 0.f, Metric::PopUpTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
app()->displayModalViewController(box, 0.f, 0.f, Metric::PopUpTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
return true;
}
return false;

View File

@@ -174,7 +174,7 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) {
if (m_delegate && m_delegate->layoutFieldDidReceiveEvent(this, event)) {
return true;
}
if (handleBoxEvent(app(), event)) {
if (handleBoxEvent(event)) {
if (!isEditing()) {
setEditing(true);
}

View File

@@ -1,4 +1,3 @@
#include <escher/app.h>
#include <escher/text_area.h>
#include <escher/clipboard.h>
#include <escher/text_input_helpers.h>
@@ -97,7 +96,7 @@ bool TextArea::handleEventWithText(const char * text, bool indentation, bool for
bool TextArea::handleEvent(Ion::Events::Event event) {
if (m_delegate != nullptr && m_delegate->textAreaDidReceiveEvent(this, event)) {
return true;
} else if (handleBoxEvent(app(), event)) {
} else if (handleBoxEvent(event)) {
return true;
} else if (event == Ion::Events::Left) {
return TextInput::moveCursorLeft();

View File

@@ -1,4 +1,3 @@
#include <escher/app.h>
#include <escher/text_field.h>
#include <escher/text_input_helpers.h>
#include <escher/clipboard.h>
@@ -278,7 +277,7 @@ void TextField::setEditing(bool isEditing, bool reinitDrafBuffer) {
bool TextField::privateHandleEvent(Ion::Events::Event event) {
// Handle Toolbox or Var event
if (handleBoxEvent(app(), event)) {
if (handleBoxEvent(event)) {
if (!isEditing()) {
setEditing(true);
}