fsetState on popup LIST

A PocketC native palm library offering native forms and assorted utilities

fsetState on popup LIST

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

Using fsetState on a button bound popup list sets the item as expected.
Hoever, when the list pops-up after pressing the button, it will not be positioned at the selected item.
There seems to be no way to do this with PocketC / Toolbox.
I can find no equivalent to the API function LstSetTopItem which is needed to do this.
Can anyone help ?
kalisco
 
Posts: 8
Joined: Wed Apr 16, 2008 8:15 pm

Re: fsetState on popup LIST

Postby kalisco on Wed Apr 30, 2008 4:47 pm

Here I go replying to myself again !

In a nutshell you can't do this with Pocket Toolbox - one of the problems of using a library with no source, I guess.
So I tried it with Ccontrols, and got the same problem !
However, Ccontrols can be modified to get this to work, as follows :-

//Modify 1 line in this function in cControls2.c as shown - do keep a backup !
Cdrp(pointer p)
{
int t,x,y,r;
t=0;r=0;x=p[1];y=p[2];
if(p[0]==8)
p[2]=14;
if(x+p[3]>158)
p[1]=158-p[3];
if(y+p[4]>158)
p[2]=158-p[4];
if(p[0]==8)
rect(0,p[1]-2,p[2]+1,p[1]+p[3]+3,p[2]+p[4]+3,0);
else
rect(0,p[1]-2,p[2]-2,p[1]+p[3]+3,p[2]+p[4]+3,0);
frame(1,p[1],p[2],p[1]+p[3],p[2]+p[4],1);
line(1,p[1]+1,p[2]+p[4]+1,p[1]+p[3]-2,p[2]+p[4]+1);
line(1,p[1]+p[3]+1,p[2]+1,p[1]+p[3]+1,p[2]+p[4]-2);
///p[5]=0; This allows Csettopitm to work
Cdlbi(p);
if(p[0]==10)
{
t=1;
p[0]=11;
}
while(1)
{
if(event(1)==2)
if(Cc(p))
{
if(Chl(p))
{
r=1;
break;
}
}
else
{
r=0;
break;
}
}
if(t)
p[0]=10;
p[1]=x;
p[2]=y;
return r;
}

Add this new function :-

Csettopitm(pointer p, int s)
{
if ((p[0]>6)&&(p[0]<14))
{
p[5]=s;
return 1;
}
else
return 0;
}

Here's a quick example :-

//Test
#include "cControls.c"
Chandle ddlTest;

init()
{
int i;

graph_on();
clearg();
ddlTest=Cdropdown(1,20,140,12);
Csetsize(ddlTest,400);
for (i=100;i<500;i++)
{
Cadditem(ddlTest,i);
}
Cdraw(ddlTest);
}

main()
{
int Evt;
init();
while(1)
{
while (1)
{
Evt=event(1);
if (Cevent(ddlTest,Evt));
Csettopitm(ddlTest,Cgetcursel(ddlTest));
}
}
}

You should notice that when the list pops-up the previously selected item is always at the top.
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 0 guests

cron