How can I automatically select text in edit field ?

A PocketC native palm library offering native forms and assorted utilities

How can I automatically select text in edit field ?

Postby kalisco on Fri Apr 18, 2008 7:56 pm

HI,
Hope someone can help.
Here's the basic form I'm using.
I'll be entering the fields in this form then pressing the button.
Then repeating this many times.
What I'd like to do is have the text in the field highlighted when I single click on the field or TAB to it on a keyboard (exactly as if I'd double clicked it), so that anything typed overwrote the existing contents.
I've tried everything I can think of with Fctl(SELALL), but with no luck.
Thanks.

main()
{
int evt;

clear();

Form(FORM1,"Predictor");
Field(AEDIT2,0x1001,120,80,30,0,2,"");
Field(AEDIT1,0x1001,60,80,30,0,2,"");
Field(DEDIT2,0x1001,120,50,30,0,2,"");
Field(DEDIT1,0x1001,60,50,30,0,2,"");
Field(HEDIT2,0x1001,120,20,30,0,2,"");
Field(HEDIT1,0x1001,60,20,30,0,2,"");
Button(PBUTTON,0,30,130,100,0,"Press for Prediction");

Fctl(DRAW,FORM1);

text(10,20,"HOME :");
text(100,20,"to");
text(10,50,"DRAW :");
text(100,50,"to");
text(10,80,"AWAY :");
text(100,80,"to");

while (1)
{
evt=Fevent(1);
//if (evt==PBUTTON)
//predict();
}

}
kalisco
 
Posts: 8
Joined: Wed Apr 16, 2008 8:15 pm

Works with keyboard - no joy with stylus

Postby kalisco on Sat Apr 26, 2008 4:54 pm

Well, I got it to work fine with an external keyboard, no need for stylus at all.
TAB to move between fields.
ENTER to press the button.
But with stylus input, it seems to be impossible; at least with PocketC / Toolbox.

//Predictor
library "PToolboxLib"
#include "..\\include\\Fctl.h"

#define FORM1 3000
#define HEDIT1 3001
#define HEDIT2 3002
#define DEDIT1 3003
#define DEDIT2 3004
#define AEDIT1 3005
#define AEDIT2 3006
#define PBUTTON 3007

int H1,H2,D1,D2,A1,A2;
char Key;

int CanUse(int Odd1,int Odd2)
{
int Ret=false;
int Tot,Val;

Tot=Odd1+Odd2;
Val=random(Tot)+1;
if (Val<=Odd2)
Ret=true;
return Ret;
}

predict()
{
int Use[3];
int Done,Used;
string Result;

H1=(int)FgetText(HEDIT1);
H2=(int)FgetText(HEDIT2);
D1=(int)FgetText(DEDIT1);
D2=(int)FgetText(DEDIT2);
A1=(int)FgetText(AEDIT1);
A2=(int)FgetText(AEDIT2);

Done=false;
while (!Done)
{
Use[0]=CanUse(H1,H2);
Use[1]=CanUse(D1,D2);
Use[2]=CanUse(A1,A2);
Done=Use[0]||Use[1]||Use[2];
}

Done=false;
while (!Done)
{
Used=random(3);
if (Use[Used])
Done=true;
}

if (Used==0)
Result="HOME";
else
if (Used==1)
Result="DRAW";
else
if (Used==2)
Result="AWAY";
else
Result="ERROR !";

alert("Prediction : "+Result);
}

main()
{
int evt;
int PrevID;
int DoneIt;
int FieldChange=true;

clear();

Fctl(HOOKTAB,1);
Fctl(BINDKEY,&Key);

Form(FORM1,"Predictor2");
Field(HEDIT1,0x1001,60,20,30,0,2,"");
Field(HEDIT2,0x1001,120,20,30,0,2,"");
Field(DEDIT1,0x1001,60,50,30,0,2,"");
Field(DEDIT2,0x1001,120,50,30,0,2,"");
Field(AEDIT1,0x1001,60,80,30,0,2,"");
Field(AEDIT2,0x1001,120,80,30,0,2,"");

Button(PBUTTON,0,30,130,100,0,"Press for Prediction");

Fctl(DRAW,FORM1);

Fctl(SETFOCUS,HEDIT1);


text(10,20,"HOME :");
text(100,20,"to");
text(10,50,"DRAW :");
text(100,50,"to");
text(10,80,"AWAY :");
text(100,80,"to");

PrevID=0;
while (1)
{
if ((Fctl(GETFOCUS)!=PrevID))
{
Fctl(SELALL);
PrevID=Fctl(GETFOCUS);
}

evt=Fevent(1);
if ((evt==PBUTTON)||
((evt==1) && (Key=='\n')))
{
predict();
Fctl(SETFOCUS,HEDIT1);
}
}

}
kalisco
 
Posts: 8
Joined: Wed Apr 16, 2008 8:15 pm


Return to Pocket Toolbox

Who is online

Users browsing this forum: No registered users and 2 guests