mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 09:10:48 +01:00
[escher][apps] CHange textField API
Change-Id: I766d153b7f7429473f297707a08358051123accc
This commit is contained in:
@@ -1,57 +1,53 @@
|
||||
#include "editable_value_cell.h"
|
||||
#include "../../apps_container.h"
|
||||
#include <assert.h>
|
||||
#include "../app.h"
|
||||
|
||||
namespace Graph {
|
||||
|
||||
EditableValueCell::EditableValueCell() :
|
||||
ValueCell(),
|
||||
EvenOddCell(),
|
||||
Responder(nullptr),
|
||||
m_textField(TextField(this, m_textBody, 255, nullptr)),
|
||||
m_isEditing(false),
|
||||
m_successAction(Invocation(nullptr, nullptr))
|
||||
m_textField(TextField(this, m_textBody, m_draftTextBody, 255, nullptr, 1.0f, 0.5f, KDColorBlack, KDColorWhite))
|
||||
{
|
||||
}
|
||||
|
||||
const char * EditableValueCell::editedText() const {
|
||||
void EditableValueCell::setDelegate(TextFieldDelegate * delegate) {
|
||||
m_textField.setTextFieldDelegate(delegate);
|
||||
}
|
||||
|
||||
void EditableValueCell::reloadCell() {
|
||||
EvenOddCell::reloadCell();
|
||||
m_textField.setBackgroundColor(backgroundColor());
|
||||
}
|
||||
|
||||
const char * EditableValueCell::text() const {
|
||||
return m_textField.text();
|
||||
}
|
||||
|
||||
void EditableValueCell::setText(const char * textContent) {
|
||||
m_textField.setText(textContent);
|
||||
}
|
||||
|
||||
int EditableValueCell::numberOfSubviews() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
View * EditableValueCell::subviewAtIndex(int index) {
|
||||
assert(index == 0);
|
||||
if (m_isEditing) {
|
||||
return &m_textField;
|
||||
}
|
||||
return &m_bufferTextView;
|
||||
return &m_textField;
|
||||
}
|
||||
|
||||
void EditableValueCell::layoutSubviews() {
|
||||
m_bufferTextView.setFrame(bounds());
|
||||
m_textField.setFrame(bounds());
|
||||
}
|
||||
|
||||
bool EditableValueCell::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK) {
|
||||
m_isEditing = false;
|
||||
m_successAction.perform(this);
|
||||
app()->setFirstResponder(parentResponder());
|
||||
return true;
|
||||
}
|
||||
m_isEditing = false;
|
||||
app()->setFirstResponder(parentResponder());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void EditableValueCell::editValue(const char * initialText, int cursorPosition, void * context, Invocation::Action successAction) {
|
||||
markRectAsDirty(bounds());
|
||||
App * myApp = (App *)app();
|
||||
m_textField.setTextFieldDelegate(myApp);
|
||||
void EditableValueCell::didBecomeFirstResponder() {
|
||||
app()->setFirstResponder(&m_textField);
|
||||
m_isEditing = true;
|
||||
m_textField.setText(initialText);
|
||||
m_textField.setCursorLocation(cursorPosition);
|
||||
m_successAction = Invocation(successAction, context);
|
||||
}
|
||||
|
||||
void EditableValueCell::setEditing(bool isEditing) {
|
||||
m_textField.setEditing(isEditing);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user