Browse Source

Fix TextField dragging for highlighting text. Add more error messages to plugin::logIn.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
380d634308
3 changed files with 24 additions and 19 deletions
  1. +1
    -1
      include/ui/TextField.hpp
  2. +19
    -12
      src/plugin.cpp
  3. +4
    -6
      src/ui/TextField.cpp

+ 1
- 1
include/ui/TextField.hpp View File

@@ -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;


+ 19
- 12
src/plugin.cpp View File

@@ -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() {


+ 4
- 6
src/ui/TextField.cpp View File

@@ -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;
}
}



Loading…
Cancel
Save