SetFocus to element in array

SetFocus to element in array

Postby Colin Haig » Thu Feb 26, 2009 8:53 am

Hi All

I have a browse (twbrowse ) with an array - I am trying to reset the browse incrementally as I search ,
ascan is returning the element I want but I not sure how to reset the browse focus to that
element.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: SetFocus to element in array

Postby Marcelo Via Giglio » Thu Feb 26, 2009 11:49 am

Hi,

did you try with oLbx:goto( nAt ) where nAt is the array element position ?

regards

MArcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: SetFocus to element in array

Postby Colin Haig » Thu Feb 26, 2009 1:45 pm

Thanks Marcelo

But goto is not a method of twbrowse

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: SetFocus to element in array

Postby James Bott » Thu Feb 26, 2009 2:04 pm

Colin,

Have you tried just setting oLbx:nAt to the value you want, then doing a refresh?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SetFocus to element in array

Postby driessen » Thu Feb 26, 2009 2:06 pm

Colin,

Suppose that nNr = the number of the selected element in the array, isn't this example working ?

oLbx:nAt := nNr
oLbx:Refresh()

Good luck.
Last edited by driessen on Thu Feb 26, 2009 2:07 pm, edited 1 time in total.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: SetFocus to element in array

Postby driessen » Thu Feb 26, 2009 2:06 pm

Otto,

You were just a fraction of a second quicker than I was, but with the same suggestion.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: SetFocus to element in array

Postby Colin Haig » Thu Feb 26, 2009 10:48 pm

Thanks All but still not working

@ 12,375 GET oValue1 VAR cValue1 picture '@' UPDATE of oBar SIZE 200,20 ;
on change(if(oValue1:nLastKey>32,chr(oValue1:nLastKey),""),nFnd := ascan(aData,trim(oValue1:cText)),;
if(oValue1:nLastkey==13,(oValue1:Hide(),oValue1:oJump(oLbx),oLbx:SetFocus(),oLbx:GoToCol(1)),(oLbx:nAt := nFnd,oLbx:Refresh()))) ;
FONT oFont ;
PIXEL

I have checked that the ascan is giving me the right item number - nFnd

Any other thoughts

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: SetFocus to element in array

Postby TimStone » Fri Feb 27, 2009 12:40 am

Colin,

I had some problems with arrays and tsBrowse ( derivative of twBrowse ). My problems had to do with adding an element to the array, and not being able to see it on the browse.

The bottom line is that I had to do a re-load of the array to the browse and then reposition to the proper element. At that point I could get it into focus.

You may have to experiment a bit to see how the array is being maintained in the browse.

Tim
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SetFocus to element in array

Postby James Bott » Fri Feb 27, 2009 1:58 am

Colin,

>Any other thoughts

I think your code is too complex to just test if setting nAt will work. It could be something else in your code that is causing the problem.

I suggest creating a VERY simple example that just displays the browse, then with the press of a button resets nAt and does a refresh. If that doesn't work then post your sample code and maybe we can solve it.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SetFocus to element in array

Postby James Bott » Fri Feb 27, 2009 2:13 am

Colin,

Here is another thought. You are using oLbx:goToCol( 1 ) in your code. I see no method by that name in TWBrowse nor in TControl or TWindow (the parent classes). Are you perhaps using a different browse or a modified version of TWBrowse?

I just did a search of all the FWH source code and the only PRG containing "gotocol" is TEDITOR.PRG so either your code has an error or you are using a modified browse class.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SetFocus to element in array

Postby Colin Haig » Fri Feb 27, 2009 2:29 am

Hi James

I am using Hernan's twbrowse.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: SetFocus to element in array

Postby Marcelo Via Giglio » Fri Feb 27, 2009 11:50 am

Colin Haig wrote:Thanks Marcelo

But goto is not a method of twbrowse

Cheers

Colin


Colin you are right, was my mistake sorry,

but the other sugestions should work

oLbx:nAt := ArrayPosition
oLbx:refresh()

I tested with Hernan's browse and this work

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: SetFocus to element in array

Postby Colin Haig » Sat Feb 28, 2009 12:33 am

Hi Marceo

I have tried

// This works
DEFINE BUTTON oBtn5 of oBar RESOURCE "FIND" ;
FLAT ;
PROMPT 'Find' ;
ACTION(oLbx:skip(20),oLbx:Refresh()) ;
TOOLTIP('Find Value')

// This Does Not Work
DEFINE BUTTON oBtn5 of oBar RESOURCE "FIND" ;
FLAT ;
PROMPT 'Find' ;
ACTION(oLbx:nAt := 20,oLbx:Refresh()) ;
TOOLTIP('Find Value')

Regards

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: SetFocus to element in array

Postby Colin Haig » Sat Feb 28, 2009 3:12 am

To All

This Works
@ 12,375 GET oValue1 VAR cValue1 picture '@' UPDATE of oBar SIZE 200,20 ;
on change(if(oValue1:nLastKey>32,chr(oValue1:nLastKey),""),nItem := ascan(aData,trim(oValue1:cText)),;
if(oValue1:nLastkey==13,(oValue1:Hide(),oValue1:oJump(oLbx),oLbx:SetFocus(),oLbx:GoToCol(1)),(aData[nItem],oLbx:Refresh()))) ;
FONT oFont ;
PIXEL

When I use oLbx:nAt := nValue then tested with MsgInfo(oLbx:nAt) it showed nValue but the
browse would not refresh to the new value.

Regards

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests

cron