termux-gui-bash icon indicating copy to clipboard operation
termux-gui-bash copied to clipboard

Termux:Gui Widget not clickable

Open joshebosh opened this issue 2 years ago • 1 comments

I can update the text on my Widget via bash script, but I'm unable to click the widget to make it update.

I have this code in the script to listen for the click

        if [ "$(tg_event_type "$ev")" = "$tgc_ev_remote_click" ]; then
                printf "widget clicked\n"
        fi

the output never gets printed... And i'm not seeing any particular function to explicitly make the widget clickable... am I missing something?

Here's the whole script as is

#!/bin/tgui-bash
set -u
wid="c1fbd68b-1516-47ed-81a3-5393d66548b5"
while true; do
        ev="$(tg_msg_recv_event_blocking)"

        #ev="$(tg_msg_recv_event)"
        if [ "$(tg_event_type "$ev")" = "$tgc_ev_remote_click" ]; then
                printf "widget clicked\n"
        fi

        text="this is a test $RANDOM"
        # Create a remote layout and TextView
        rl="$(tg_remote_create_layout)"
        #printf "rl:$rl\n"
        rt="$(tg_remote_create_text "$rl")"
        #printf "rt:$rt\n"

        #tg_view_bg_color "$rl" "$rt" "FFFFFFFF"

        # Set the text
        tg_remote_text_color "$rl" "$rt" "FFFF0000"
        tg_remote_bg_color "$rl" "$rt" "FFCCCCCC"
        tg_remote_text_size "$rl" "$rt"  "20"
        tg_remote_text "$rl" "$rt" "$text"
        tg_remote_padding "$rl" "$rt" "20" "20" "20" "20"
        # Set the widget layout and destroy the remote layout again
        tg_widget_layout "$rl" "$wid"
        tg_remote_delete_layout "$rl"
        sleep 2
        #exit 0
done

joshebosh avatar Aug 15 '23 04:08 joshebosh

The remote click event isn't triggered by clicking the widget, only by clicking a remote button in the layout. If that also doesn't work, I'll have to look into it further. The widget system needs an overhaul anyways for Android 12 widgets, and was never tested much.

tareksander avatar Oct 21 '23 13:10 tareksander