зеркало из https://github.com/electron/electron.git
feat: add SetText for TextField
This commit is contained in:
Родитель
70e17b5f8f
Коммит
a11182ca84
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "atom/common/api/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/views/controls/textfield/textfield.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -20,6 +19,14 @@ TextField::TextField() : View(new views::Textfield()) {
|
|||
|
||||
TextField::~TextField() {}
|
||||
|
||||
void TextField::SetText(const base::string16& new_text) {
|
||||
text_field()->SetText(new_text);
|
||||
}
|
||||
|
||||
base::string16 TextField::GetText() const {
|
||||
return text_field()->text();
|
||||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* TextField::New(mate::Arguments* args) {
|
||||
// Constructor call.
|
||||
|
@ -32,6 +39,9 @@ mate::WrappableBase* TextField::New(mate::Arguments* args) {
|
|||
void TextField::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "TextField"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setText", &TextField::SetText)
|
||||
.SetMethod("getText", &TextField::GetText);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_view.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "ui/views/controls/textfield/textfield.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -19,10 +20,17 @@ class TextField : public View {
|
|||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
void SetText(const base::string16& new_text);
|
||||
base::string16 GetText() const;
|
||||
|
||||
private:
|
||||
TextField();
|
||||
~TextField() override;
|
||||
|
||||
views::Textfield* text_field() const {
|
||||
return static_cast<views::Textfield*>(view());
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(TextField);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче