combobox

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

Re: combobox

Post by James Bott »

Ok, here is a fix. There are just two lines that need to be changed.

James

Code: Select all

METHOD KeyChar( nKey, nFlags ) CLASS TComboBox
      ...
         otherwise
              ::cSearchKey += Upper( Chr( nKey ) )  // JBott
      endcase

      if Empty( uItem )
         if nNewAt == 0
            nNewAt = AScan( ::aItems, {|x| Upper( x ) = ::cSearchKey } ) // JBott
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: combobox

Post by James Bott »

Here is my test code.

James

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oCbx, cVar := ""

    LOCAL aArray:= { "", "Alpha", "Pippo", "Pluto", "Paperino","Pblano" }
    asort(aArray)

    DEFINE DIALOG oDlg

    @ 1, 1 COMBOBOX oCbx VAR cVar;
           ITEMS aArray

    oCbx:lIncSearch = .T.

    @ 3, 1 BUTTON "Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: combobox

Post by Antonio Linares »

Enrico's example works fine if Caps is pressed for the first typed char.

James enhacement avoids the use of Caps.

Unless I am missing something
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: combobox

Post by James Bott »

Antonio,

Yes, I finally found that it was case sensitive. Enrico's sample is not is sorted order either so that is also a problem.

As we have found, even us programmers didn't think to try case sensitive input. So, I doubt that the users will. This is why I think it should be case insensitive.

James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: combobox

Post by Antonio Linares »

James,

Yes, you are right. In order to avoid potential users errors lets implement your fixes, thanks :-)

Edited: Already implemented for next FWH build
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
frose
Posts: 327
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Gütersloh
Contact:

Re: combobox

Post by frose »

Hi,

the logic (cas sensitive/insensitive) should be adjustable by the developer or user, because sometimes - especially in the german language - there can be importend differences in the orthography regarding lower and upper cases :wink: , and when you want to differentiate in the logic...
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: combobox

Post by James Bott »

Frank's suggestion could be useful. I suggest defaulting the class to NOT be case sensitive so it doesn't break existing code.

Below is the modified code to make case sensitive optional.

James

Code: Select all

   DATA ::lCaseSensitive := .F.

...

METHOD KeyChar( nKey, nFlags ) CLASS TComboBox
      ...
         otherwise
            if ::lCaseSensitive
               ::cSearchKey += Chr( nKey )
            else
              ::cSearchKey += Upper( Chr( nKey ) )
            endif
      endcase

      if Empty( uItem )
         if nNewAt == 0
            if ::lCaseSensitive
               nNewAt = AScan( ::aItems, {|x| x = ::cSearchKey } )
            else
               nNewAt = AScan( ::aItems, {|x| Upper( x ) = ::cSearchKey } )
            endif
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: combobox

Post by Antonio Linares »

James,

Implemented for next FWH build :-)

Thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
frose
Posts: 327
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Gütersloh
Contact:

Re: combobox

Post by frose »

I love FWH :D
jds
Posts: 106
Joined: Sat Dec 05, 2009 12:44 pm

Re: combobox

Post by jds »

Thank you James if you can find a solution
kind regards
José
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: combobox

Post by James Bott »

Jose,
Thank you James if you can find a solution
I am not sure what you meant by that. I did find a solution.

Is the combobox now working for you or not? If not, what version of FWH are you using? Did you make the changes to TCombobox that I posted? Are you using the sample test code I provided?

Regards,
James
jds
Posts: 106
Joined: Sat Dec 05, 2009 12:44 pm

Re: combobox

Post by jds »

James,
Thank you for your test code of Sun Jul 04, 2010 8:40 pm
I compiled it with my FWH 9.11 that I buyed some 6 months ago
The compiling gives no problems but the incremental search still do not work
Do I need a more recent version of FWH and so Yes, can I download it for free with my 9.11 licence?
Kind regards
José (Belgium) non prof. user
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: combobox

Post by James Bott »

Jose,

If you will email me a copy of your COMBOBOX.PRG, I will test it here.

jbott at compuserve dot com

If I find that version doesn't work, you will need to upgrade to a new version of FWH. You can not get this for free.

Regards,
James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: combobox

Post by Antonio Linares »

James,

If it is a bug in his version, then there is no problem to provide him the fixed combobox :-)

thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
jds
Posts: 106
Joined: Sat Dec 05, 2009 12:44 pm

Re: combobox

Post by jds »

James,
I simply compiled your test code

#include "Fivewin.ch"


FUNCTION MAIN()

LOCAL oDlg

LOCAL oCbx, cVar := ""

LOCAL aArray:= { "", "Alpha", "Pippo", "Pluto", "Paperino","Pblano" }
asort(aArray)

DEFINE DIALOG oDlg

@ 1, 1 COMBOBOX oCbx VAR cVar;
ITEMS aArray

oCbx:lIncSearch = .T.

@ 3, 1 BUTTON "Close";
ACTION oDlg:End()

ACTIVATE DIALOG oDlg;
CENTER

RETURN NIL

Kind regards
José
Post Reply