Creating timestamps on button press

This is for KWGT v3.74 on a Lenovo Tab P12, android version 13.

I want to display a timestamp when I press an on-screen button, and each button needs its own independent timestamp. So, I have 2 buttons, 1 to toggle global switch ts1, and the other to toggle global switch ts2. Both globals are $df(MMMM d hh:mm)$. Button 1 has a corresponding text box with $gv(ts1)$, and button 2 has its own text box with $gv(ts2)$.

The problem is that whichever button I press, it updates the timestamp in both text boxes. Also, when I am in editing mode, the text boxes run like a clock instead of showing static times. Is toggling a global variable (text) not the way to go about this? Is having the same formula as 2 globals messing things up?

I cannot reproduce this, what i did is:

  • Created global TS1 and TS2
  • Added a touch action to Button 1 to switch global value with target TS1 and value $df(hh:mm:ss)$
  • Did the same for button 2 for TS2
  • They switch correctly, you can test this using the attached Komponent (just import it when adding a Komponent)
    GvSwitch.komp (113.2 KB)

Another option is to use a flow:

  • Create a new flow for TS1
  • Add a “manual trigger”
  • Add a formula action with your formula $df(MMMM d hh:mm)$
  • Add a set global action setting your global TS1
  • Do the same for TS2

If you do not want to import the Komponent you can also copy paste it from here:

##KUSTOMCLIP##
{
  "clip_version": 1,
  "clip_cut": [],
  "clip_modules": [
    {
      "internal_type": "KomponentModule",
      "internal_title": "GvSwitch",
      "config_scale_value": 350.0,
      "globals_list": {
        "gv1": {
          "index": 1,
          "type": "TEXT",
          "title": "gv1",
          "value": "03:38:26"
        },
        "gv2": {
          "index": 2,
          "type": "TEXT",
          "title": "gv2",
          "value": "03:38:25"
        }
      },
      "viewgroup_items": [
        {
          "internal_type": "StackLayerModule",
          "viewgroup_items": [
            {
              "internal_type": "TextModule",
              "text_expression": "GV1 $gv(gv1)$",
              "internal_events": [
                {
                  "type": "SINGLE_TAP",
                  "action": "SWITCH_GLOBAL",
                  "switch": "gv1",
                  "switch_text": "$df(hh:mm:ss)$"
                }
              ]
            },
            {
              "internal_type": "TextModule",
              "text_expression": "GV2 $gv(gv2)$",
              "internal_events": [
                {
                  "type": "SINGLE_TAP",
                  "action": "SWITCH_GLOBAL",
                  "switch": "gv2",
                  "switch_text": "$df(hh:mm:ss)$"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
##KUSTOMCLIP##

I imported your komponent and it works just fine! Thank you! I also built the flow like you described, and that worked as well. I appreciate your help. I’m re-installing KWGT just in case it’s a weird bug

Glad it worked out! Maybe you have a misspelled global or touch, reinstall should not be necessary