oGet:setSel() not working?

oGet:setSel() not working?

Postby James Bott » Fri Feb 03, 2006 4:07 pm

I can't seem to get the setSel() method of the TGet class to work. The following code doesn't show any highlighted text.

Code: Select all  Expand view
#include "fivewin.ch"

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update

   activate dialog oDlg;
      on init (oGet:setSel(2,5), oGet:refresh())

return nil


It doesn't work with FWH 2.6, May 2005 build/Harbour 43, nor with Clipper. Am I doing something wrong, or maybe setSel() does something else?

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

Re: oGet:setSel() not working?

Postby Enrico Maria Giordano » Fri Feb 03, 2006 5:54 pm

This is a working sample:

Code: Select all  Expand view
#include "fivewin.ch"

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update

   oDlg:bStart = { || oGet:SetSel(2,5) }

   activate dialog oDlg;
//      on init (oGet:setSel(2,5), oGet:refresh())

return nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Feb 03, 2006 8:11 pm

Enrico,

How odd. When I use the ON INIT it actually preprocesses to this:

{ |self| oGet:SetSel(2,5) }

If I do:

oDlg:bInit:= { |self| oGet:SetSel(2,5) }

It works just like you said also. But the same code doesn't work when assigned via the ON INIT clause. Strange.

I also tried doing it from a button action, but that wouldn't work either. I really need to do it via the GET's ON CHANGE clause. I have tried this:

@ 2,2 get oGet var cString of oDlg update on change oGet:setSel(2,5)

But that doesn't work either. The GET must be getting refreshed after bChange is called. I guess that is expected.

I am trying to build an autoComplete system, so I need to set the selected text after each keystroke. Any ideas?

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

Postby James Bott » Fri Feb 03, 2006 8:40 pm

Enrico,

Whoops. I didn't realize you were using oDlg:bStart NOT oDlg:bInit. bInit does not work, but bStart does. Now I get it.

I still need to figure out how to highlight text after each keystroke. I tried bKeydown also and that doesn't work either.

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

Postby Enrico Maria Giordano » Fri Feb 03, 2006 9:58 pm

Try this:

Code: Select all  Expand view
#include "fivewin.ch"

#define EM_SETSEL      177

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update on change oGet:PostMsg( EM_SETSEL, 2, 5 )

   activate dialog oDlg

return nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Fri Feb 03, 2006 10:05 pm

Enrico,

Wow, that seems to work!

I had already tried:

SendMessage( oGet:hWnd, EM_SETSEL, 2, 5 )

but that didn't work.

Thanks a lot.

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

Postby Enrico Maria Giordano » Fri Feb 03, 2006 10:12 pm

You're welcome, James! By the way, can we have the honour to see your face? :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby tnhoe » Sat Feb 04, 2006 12:31 am

James,

Sandeep's TDD class does it : Auto-complete from dbf

I use it since fw 1.95

U can download it from Patrick Mast's www.fivewin.info
Regards

Hoe, email: easywin3@yahoo.com
User avatar
tnhoe
 
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia

Postby James Bott » Sat Feb 04, 2006 4:11 am

Hoe,

Thanks. I'll take a look. I do have mine working also, so it will be interesting to see how he did it too.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 79 guests