oGet:setSel() not working?

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

oGet:setSel() not working?

Post by James Bott »

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

#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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: oGet:setSel() not working?

Post by Enrico Maria Giordano »

This is a working sample:

Code: Select all

#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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Try this:

Code: Select all

#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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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

EMG
User avatar
tnhoe
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia
Contact:

Post by tnhoe »

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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
Post Reply