From a2ad0b555226b262e21d0b2e68304f227abbc24d Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 8 Jan 2016 13:35:21 -0500
Subject: [PATCH] allow gatom to have an "activated" text color

---
 pd/nw/css/default.css |  5 +++++
 pd/nw/pdgui.js        | 10 ++++++++++
 pd/src/g_text.c       |  8 ++++++++
 3 files changed, 23 insertions(+)

diff --git a/pd/nw/css/default.css b/pd/nw/css/default.css
index 6da6a3709..c683b33bc 100644
--- a/pd/nw/css/default.css
+++ b/pd/nw/css/default.css
@@ -264,6 +264,11 @@ text {
     fill: blue;
 }
 
+/* gatom "activated" text (i.e., when it has the keyboard focus) */
+.atom.activated text {
+    fill: red;
+}
+
 /* test of xlet hover animation... this should 
    probably use the web animation API instead. That
    way the animation won't get cut off when you
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 420b6183a..051b4a294 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -3193,6 +3193,16 @@ function gui_gatom_dialog(did, attr_array) {
         attr_array_to_object(attr_array));
 }
 
+function gui_gatom_activate(cid, tag, state) {
+    var g = get_gobj(cid, tag);
+    if (state !== 0) {
+        g.classList.add("activated");
+    } else {
+        g.classList.remove("activated");
+    }
+    post("activating gatom: cid is " + cid + " and tag is " + tag + " and t is " + t);
+}
+
 function gui_iemgui_dialog(did, attr_array) {
     //for (var i = 0; i < attr_array.length; i++) {
     //    attr_array[i] = '"' + attr_array[i] + '"';
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 1b0b402cb..97e2b1876 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -878,6 +878,10 @@ static void gatom_retext(t_gatom *x, int senditup, int recolor)
     {
         //sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
         //    rtext_gettag(y), "$pd_colors(text)");
+        gui_vmess("gui_gatom_activate", "xsi",
+            canvas,
+            rtext_gettag(y),
+            0);
     }
     binbuf_clear(x->a_text.te_binbuf);
     binbuf_add(x->a_text.te_binbuf, 1, &x->a_atom);
@@ -1818,6 +1822,10 @@ static int text_click(t_gobj *z, struct _glist *glist,
             /* Change the gatom blue when it's clicked? Need to test... */
             sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
                 rtext_gettag(y), "$pd_colors(selection)");
+            gui_vmess("gui_gatom_activate", "xsi",
+                canvas,
+                rtext_gettag(y),
+                1);
             gatom_click((t_gatom *)x, (t_floatarg)xpix, (t_floatarg)ypix,
                 (t_floatarg)shift, (t_floatarg)0, (t_floatarg)alt);
         }
-- 
GitLab