How to use Focus and Enter keys? (Solved)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

How to use Focus and Enter keys? (Solved)

#1 Post by arivas_2005 »

greetings
excuse my english

i have a little example in gtk

Code: Select all

#! /bin/bash
export DIALOG='
<window title="PERSONAL UNIT OR FOLDER" resizable="true" icon-name="computer">
 <vbox>
    <checkbox>
      <variable>CHECKBOX</variable>
      <label>FOLDER COMMON</label>
    </checkbox>
    <text use-markup="true" width-chars="40">
       <label>INPUT PERSONAL UNIT</label>
    </text>
    <entry xalign="0.5" is-focus="true">  
      <default>User Input</default>
      <variable>NAME1</variable>
      <action signal="activate">command</action>            
   </entry>
   <entry>
     <default>Password Input</default>
     <variable>NAME2</variable>
   </entry>   
   <hbox>
    <button ok></button>
    <button cancel></button>
   </hbox>
  </vbox>
 </window>
'
I=$IFS; IFS=""
for DECLARNAME in  $(gtkdialog --center --program DIALOG); do
  eval $DECLARARNOMBRE
done
IFS=$I
=============
How i can to pass focus of "User Input" to "Password Input" texbox using enter key?

or
fill textbox "User Input" and press [enter] then
... the focus should move to the second box, then newly I fill textbox "Passworod Input", then
I press to enter key.... pass the focus to button OK, and finally press to enter key for end

newlly, excuse my english.
(I used google traslate)
thanks
Last edited by arivas_2005 on Thu 02 May 2013, 18:21, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

focus

#2 Post by L18L »

I am afraid you cannot...

But old users (like me) are used to take the TAB key for jumping to next input field. That works :wink:
Attachments
focus.png
(55.95 KiB) Downloaded 240 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#3 Post by SFR »

Hmm, actually it's possible, but only in Gtkdialog >= 0.8.1:

Code: Select all

<action signal="activate">grabfocus:NAME2</action>
Ref.: http://code.google.com/p/gtkdialog/wiki/entry

However I'm accustomed to use TAB key as well. :wink:

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#4 Post by thunor »

Code: Select all

#! /bin/bash
export DIALOG='
<window title="PERSONAL UNIT OR FOLDER" resizable="true" icon-name="computer">
 <vbox>
    <checkbox>
      <variable>CHECKBOX</variable>
      <label>FOLDER COMMON</label>
    </checkbox>
    <text use-markup="true" width-chars="40">
       <label>INPUT PERSONAL UNIT</label>
    </text>
    <entry xalign="0.5" is-focus="true"> 
      <default>User Input</default>
      <variable>NAME1</variable>
      <action signal="activate">grabfocus:NAME2</action>    #<<< Just as SFR stated above.
      <action signal="activate">command</action>           
   </entry>
   <entry activates-default="true">              #<<< This will activate the OK button on Enter.
     <default>Password Input</default>
     <variable>NAME2</variable>
   </entry>   
   <hbox>
    <button use-stock="true" label="gtk-ok" can-default="true" has-default="true">    #<<< Is now the default button.
    </button>
    <button cancel></button>
   </hbox>
  </vbox>
 </window>
'
I=$IFS; IFS=""
for DECLARNAME in  $(gtkdialog --center --program DIALOG); do
  eval $DECLARARNOMBRE
done
IFS=$I
Also be aware that you will be evaluating everything gtkdialog, gtk and any executed programs output with this command:

Code: Select all

for DECLARNAME in  $(gtkdialog --center --program DIALOG); do
At the least you should change it to this:

Code: Select all

for DECLARNAME in  $(gtkdialog --center --program DIALOG 2>/dev/null); do
although I quite like this:

Code: Select all

for DECLARNAME in  $(gtkdialog --center --program DIALOG | grep "^[A-Za-z0-9]*="); do
because it additionally prevents evaluating anything sent to stdout by executed programs.

Anyway, you get the idea right.

Regards,
Thunor

P.S. Don't forget to remove the "#<<<" comments from the code above.

arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

#5 Post by arivas_2005 »

Solved my problem
Thanks and greetings !

Post Reply