2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
6 #include "TableCellTextControlEditor.h"
9 #include "ValueFormatter.h"
13 MSG_INPUT_VALIDATION_NEEDED
= 'ivne',
14 MSG_TEXT_VALUE_CHANGED
= 'tevc'
18 TableCellTextControlEditor::TableCellTextControlEditor(::Value
* initialValue
,
19 ValueFormatter
* formatter
)
21 TableCellFormattedValueEditor(initialValue
, formatter
),
22 BTextControl("", "", NULL
)
27 TableCellTextControlEditor::~TableCellTextControlEditor()
33 TableCellTextControlEditor::Init()
35 BMessage
* message
= new(std::nothrow
) BMessage(
36 MSG_INPUT_VALIDATION_NEEDED
);
42 message
= new(std::nothrow
) BMessage(MSG_TEXT_VALUE_CHANGED
);
46 SetModificationMessage(message
);
53 TableCellTextControlEditor::GetView()
60 TableCellTextControlEditor::AttachedToWindow()
62 BTextControl::AttachedToWindow();
68 if (GetValueFormatter()->FormatValue(InitialValue(), output
) == B_OK
)
71 NotifyEditBeginning();
76 TableCellTextControlEditor::MessageReceived(BMessage
* message
)
78 switch (message
->what
) {
79 case MSG_TEXT_VALUE_CHANGED
:
81 // TODO: highlight the input view in some way to show
86 case MSG_INPUT_VALIDATION_NEEDED
:
88 if (ValidateInput()) {
89 ::Value
* value
= NULL
;
90 status_t error
= GetValueForInput(value
);
94 BReference
< ::Value
> valueReference(value
, true);
95 NotifyEditCompleted(value
);
100 BTextControl::MessageReceived(message
);