diff --git a/include/ui/TextField.hpp b/include/ui/TextField.hpp index 1fa54e0b..73d6670a 100644 --- a/include/ui/TextField.hpp +++ b/include/ui/TextField.hpp @@ -21,7 +21,7 @@ struct TextField : widget::OpaqueWidget { TextField(); void draw(const DrawArgs &args) override; - void onHover(const event::Hover &e) override; + void onDragHover(const event::DragHover &e) override; void onButton(const event::Button &e) override; void onSelectText(const event::SelectText &e) override; void onSelectKey(const event::SelectKey &e) override; diff --git a/src/plugin.cpp b/src/plugin.cpp index 352cd084..fcabc720 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -390,6 +390,7 @@ void destroy() { } void logIn(const std::string &email, const std::string &password) { + loginStatus = "Logging in..."; json_t *reqJ = json_object(); json_object_set(reqJ, "email", json_string(email.c_str())); json_object_set(reqJ, "password", json_string(password.c_str())); @@ -398,22 +399,28 @@ void logIn(const std::string &email, const std::string &password) { json_t *resJ = network::requestJson(network::POST, url, reqJ); json_decref(reqJ); - if (resJ) { - json_t *errorJ = json_object_get(resJ, "error"); - if (errorJ) { - const char *errorStr = json_string_value(errorJ); - loginStatus = errorStr; + if (!resJ) { + loginStatus = "No response from server"; + return; + } + + json_t *errorJ = json_object_get(resJ, "error"); + if (errorJ) { + const char *errorStr = json_string_value(errorJ); + loginStatus = errorStr; + } + else { + json_t *tokenJ = json_object_get(resJ, "token"); + if (tokenJ) { + const char *tokenStr = json_string_value(tokenJ); + settings::token = tokenStr; + loginStatus = ""; } else { - json_t *tokenJ = json_object_get(resJ, "token"); - if (tokenJ) { - const char *tokenStr = json_string_value(tokenJ); - settings::token = tokenStr; - loginStatus = ""; - } + loginStatus = "No token in response"; } - json_decref(resJ); } + json_decref(resJ); } void logOut() { diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index 12ce1f37..56645062 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -30,14 +30,12 @@ void TextField::draw(const DrawArgs &args) { nvgResetScissor(args.vg); } -void TextField::onHover(const event::Hover &e) { - OpaqueWidget::onHover(e); +void TextField::onDragHover(const event::DragHover &e) { + OpaqueWidget::onDragHover(e); - if (this == APP->event->draggedWidget) { + if (e.origin == this) { int pos = getTextPosition(e.pos); - if (pos != selection) { - cursor = pos; - } + cursor = pos; } }