]> git.ipfire.org Git - thirdparty/newt.git/blobdiff - button.c
install python modules to purelib and platlib
[thirdparty/newt.git] / button.c
index 467efdb3534e76565dd399f72f72ba94e0163fec..8eb5e5a9021f86046671c258cec48804df92eb56 100644 (file)
--- a/button.c
+++ b/button.c
@@ -45,6 +45,7 @@ static newtComponent createButton(int left, int row, const char * text, int comp
        return NULL;
     }
     co->data = bu;
+    co->destroyCallback = NULL;
 
     bu->text = strdup(text);
     bu->compact = compact;
@@ -104,10 +105,12 @@ static void buttonDrawIt(newtComponent co, int active, int pushed) {
     SLsmg_set_color(NEWT_COLORSET_BUTTON);
 
     if (bu->compact) {
-       if (active)
+       if (!active)
            SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
-       else
+       else if (SLtt_Use_Ansi_Colors)
            SLsmg_set_color(NEWT_COLORSET_BUTTON);
+       else
+           SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
        newtGotorc(co->top+ pushed, co->left + 1 + pushed);
        SLsmg_write_char('<');
        SLsmg_write_string(bu->text);
@@ -126,6 +129,8 @@ static void buttonDrawIt(newtComponent co, int active, int pushed) {
 
        buttonDrawText(co, active, pushed);
     }
+    /* put cursor at beginning of text for better accessibility */
+    newtGotorc(co->top + (bu->compact ? 0 : 1) + pushed, co->left + 1 + pushed + 1);
 }
 
 static void buttonDrawText(newtComponent co, int active, int pushed) {
@@ -149,6 +154,8 @@ static struct eventResult buttonEvent(newtComponent co,
     struct eventResult er;
     struct button * bu = co->data;
 
+    er.result = ER_IGNORED;
+
     if (ev.when == EV_NORMAL) {
        switch (ev.event) {
          case EV_FOCUS:
@@ -195,8 +202,7 @@ static struct eventResult buttonEvent(newtComponent co,
              }
            break;
        }
-    } else
-       er.result = ER_IGNORED;
+    }
 
     return er;
 }