Code: Select all
<action signal="key-press-event">[ $KEY_VAL = "0x06b" ] && gxmessage $varname</action>
Code: Select all
<action signal="key-press-event">[ $KEY_VAL = "0x06b" ] && Refresh:varname</action>
------------
Code: Select all
<action signal="key-press-event">[ $KEY_VAL = "0x06b" ] && gxmessage $varname</action>
Code: Select all
<action signal="key-press-event">[ $KEY_VAL = "0x06b" ] && Refresh:varname</action>
Code: Select all
<action signal="key-press-event" condition="command_is_true( [ $KEY_VAL = 0x06b ] && echo true )">Refresh:varname</action>
One mystery down.true means "true", "yes" or a non-zero value, false means "false", "no" or zero, therefore the shell command is expected to echo one of these values to stdout.
Yes, in this case it was indeed my intuition + /usr/share/doc/gtkdialog/examples/miscellaneous/press_and_release_events example, which is very helpful to determine correct values.Did your intuitive investigatiion by any chance led you to a solution for key-press events involving modifier keys? Would be nice to perform actions upon pressing Ctrl+K. My guess is that this is the end of the line for <action>.
Code: Select all
#!/bin/bash
# Ctrl+Shift+R to refresh the date
export MAIN='
<window>
<text>
<variable>varDATE</variable>
<input>date</input>
</text>
<action signal="key-press-event" condition="command_is_true( [ $(( ${KEY_MOD} & 5 )) = 5 ] && [ $KEY_RAW = 0x1b ] && echo true )">Refresh:varDATE</action>
</window>'
gtkdialog -cp MAIN
And this is very good workaround in some cases!My current workaround uses <menuitem> with accel-key and accel-mods, packed into an invisible menu bar. Works pretty well, is much more readable and doesn't require gtkdialog4, but after all it's a workaround.
Code: Select all
#!/bin/sh
# TriTerm v0.1 by SFR'2014
APPNAME="TriTerm v0.1"
CWD=`pwd`
export INDEX=/dev/shm/triterm_index_${$}
echo 0 > $INDEX
trap 'rm $INDEX' EXIT
#==============================================================================
func_term () {
echo '
<terminal argv0="/bin/bash"
current-directory-uri="'${CWD}'"
encoding="UTF-8"
cursor-shape="0"
scrollback-lines="10000"
font-name="10"
text-background-color="#fff"
text-foreground-color="#000"
cursor-background-color="#888"
hscrollbar-policy="1"
vscrollbar-policy="0">
<variable>varTERM_'${1}'</variable>
<width>83</width>
<height>16</height>
<action signal="child-exited">exit:EXIT</action>
</terminal>'
}
#==============================================================================
[ -e "/usr/local/lib/X11/mini-icons/mini-sh.xpm" ] && PIX_PATH="/usr/local/lib/X11/mini-icons/mini-sh.xpm" || PIX_PATH="/usr/share/pixmaps/puppy/terminal.svg"
export MAIN='
<window title="'${APPNAME}'" image-name="'${PIX_PATH}'">
<vbox space-fill="true" space-expand="true">
<notebook show-tabs="false">
<vbox>
'"`func_term 1`"'
'"`func_term 2`"'
</vbox>
<vbox>
'"`func_term 3`"'
</vbox>
<variable>varPAGE</variable>
<input file>'${INDEX}'</input>
</notebook>
<vbox space-fill="false" space-expand="false">
<menubar height-request="1" width-request="1">
<menu>
<menuitem accel-key="0x31" accel-mods="4">
<label>Top Terminal</label>
<action>echo 0 > '${INDEX}'</action>
<action>refresh:varPAGE</action>
<action>grabfocus:varTERM_1</action>
</menuitem>
<menuitem accel-key="0x32" accel-mods="4">
<label>Bottom Terminal</label>
<action>echo 0 > '${INDEX}'</action>
<action>refresh:varPAGE</action>
<action>grabfocus:varTERM_2</action>
</menuitem>
<menuitem accel-key="0x33" accel-mods="4">
<label>Full Terminal</label>
<action>echo 1 > '${INDEX}'</action>
<action>refresh:varPAGE</action>
<action>grabfocus:varTERM_3</action>
</menuitem>
<label>""</label>
</menu>
</menubar>
</vbox>
</vbox>
<action signal="delete-event">exit:abort</action>
</window>'
#==============================================================================
gtkdialog -p MAIN
exit
Code: Select all
<action signal="key-press-event" condition="command_is_true( [ $(( ${KEY_MOD} & 5 )) = 5 ] && [ $KEY_RAW = 0x1b ] && echo true )">Refresh:varDATE</action>
@zigbert. You are quick. I see that you already edited your valuable GtkDialog-Tips, but frankly I'm not sure if this is understandable for simple minded non-nerds like me. Not everybody is familiar with bitwise logical operations and I am still struggling with SFR's example. I'm sure you like it, but before I can see the beauty in this beast I want to understand it. Maybe you should wait until my problems are solved ( I need 1 or 2 more days for testing) and then, after even MochiMoppel understands this stuff, you can be sure that the explanations are foolproof.zigbert, in his GtkDialog-Tips thread, wrote:Hotkeys
>> An <action> signal inside the <window> widget gives the most direct hotkey
<action signal="key-press-event" condition="command_is_true( [ $(( ${KEY_MOD} & 5 )) = 5 ] && [ $KEY_RAW = 0x1b ] && echo true )">Refresh:varDATE</action>
Some explanations: SHIFT's state is held by by 0th bit and CTRL state by 2nd bit of $KEY_MOD variable (?????C?S) , so, in order to read their state correctly, we need to discard the rest of bits by logical AND: $(( $KEY_MOD & 5 )).
If we would want SHIFT alone, it would be $(( $KEY_MOD & 1)) = 1, only CTRL - $(( $KEY_MOD & 4 )) = 4 and so on.
>> Menuitems can set both accelerator key and modifier (SHIFT is 1, CTRL is 4 and ALT is 8 ). For a full list of accelerator key values check this
<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
A hidden menubar gives you nice solution
Code: Select all
sh-4.1# xmodmap -pm
xmodmap: up to 3 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40), Alt_L (0x7d), Meta_L (0x9c)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x7f), Hyper_L (0x80)
mod5 Mode_switch (0x5d), ISO_Level3_Shift (0x71), ISO_Level3_Shift (0x7c)
sh-4.1#
I know, but that's rather an advantage. We may not need the extra check for the Shift status:SFR wrote:Yeah, KEY_SYM/KEY_VAL might be indeed a better choice, just note that if SHIFT is pressed, the output values/characters reflect the difference (unlike KEY_RAW)
Code: Select all
<action signal="key-press-event"> [ $KEY_SYM = A ] && xmessage " Shift+A pressed"</action>
<action signal="key-press-event"> [ $KEY_SYM = a ] && xmessage " A pressed"</action>
Thanks for this hint. I seldom load devx_xxx.sfs and I haven't noticed, but I swear I downloaded it from somewhere else.../usr/share/doc/gtkdialog/examples should be in devx_xxx.sfs, but here's the online version:
Well, finally it seemed to be clear, but unfortunately it doesn't produce the expected result. $(( $KEY_MOD & 1)) = 1 checks it the Shift bit is set and and judging from the formula it doesn't care about the other modifier bits, but when running your example with this condition the variable is refreshed in cases of Shift+R, Ctrl+Shift+R, Alt+Shift+R etc. , likewise your original example refreshes in case of Crtl+Shift+Alt+RIf we would want SHIFT alone, it would be $(( $KEY_MOD & 1)) = 1, only CTRL - $(( $KEY_MOD & 4 )) = 4 and so on.
(I hope it's clear enough?)
Code: Select all
#!/bin/sh
# Shift+R to refresh the date
export MAIN='
<window>
<vbox>
<hbox>
<menubar width-request="1" height-request="1">
<menu>
<menuitem accel-key="0x52" accel-mods="1">
<action>Refresh:varDATE</action>
</menuitem>
</menu>
</menubar>
</hbox>
<text>
<variable>varDATE</variable>
<input>date</input>
</text>
</vbox>
</window>'
gtkdialog -cp MAIN
Yep, that's exactly what I mentioned in the attached txt.MochiMoppel wrote:$(( $KEY_MOD & 1)) = 1 checks it the Shift bit is set and and judging from the formula it doesn't care about the other modifier bits, but when running your example with this condition the variable is refreshed in cases of Shift+R, Ctrl+Shift+R, Alt+Shift+R etc. , likewise your original example refreshes in case of Crtl+Shift+Alt+R
However, knowing now (more or less) what those two "unknown" bits are, I think it's enough to discard only NumLock, CapsLock and Mod3 (which appears to be Scroll_Lock, not enabled by default in Puppy though).me wrote:The above method has a flaw though. If we want to probe e.g. SHIFT+some_key, discarding all other bits will return positive results also if
SHIFT+CTRL+some_key or SHIFT+ALT+some_key or SHIFT+CTRL+ALT+some_key (and so on) are pressed.
So, I think that best solution is to discard only NUMLOCK's, CAPSLOCK's (and those two unknown bits') states, in which case the AND mask will be always constant: 10001101 (141), and only the value we comparing it with will vary.
F10 has the same effect in my case.MochiMoppel wrote:4) Usually I set <menu use-underline="true"> and add <label>"_M"</label> to the menu section. Then upon hitting Alt+M the menu pops out of nowhere. At least during development useful for testing the correct assignment of the accel-keys .
Code: Select all
binding "NoKeyboardNavigation" {
unbind "<shift>F10"
}
class "*" binding "NoKeyboardNavigation"