Page 2 of 3

Re: combobox

Posted: Sun Jul 04, 2010 8:28 pm
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

Re: combobox

Posted: Sun Jul 04, 2010 8:40 pm
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

Re: combobox

Posted: Sun Jul 04, 2010 8:45 pm
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

Re: combobox

Posted: Sun Jul 04, 2010 8:55 pm
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

Re: combobox

Posted: Sun Jul 04, 2010 9:48 pm
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

Re: combobox

Posted: Mon Jul 05, 2010 7:27 am
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...

Re: combobox

Posted: Mon Jul 05, 2010 5:48 pm
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

Re: combobox

Posted: Tue Jul 06, 2010 2:59 am
by Antonio Linares
James,

Implemented for next FWH build :-)

Thanks! :-)

Re: combobox

Posted: Tue Jul 06, 2010 10:38 am
by frose
I love FWH :D

Re: combobox

Posted: Thu Jul 08, 2010 6:00 pm
by jds
Thank you James if you can find a solution
kind regards
José

Re: combobox

Posted: Thu Jul 08, 2010 10:13 pm
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

Re: combobox

Posted: Wed Jul 14, 2010 7:05 pm
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

Re: combobox

Posted: Thu Jul 15, 2010 12:16 am
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

Re: combobox

Posted: Thu Jul 15, 2010 7:28 am
by Antonio Linares
James,

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

thanks,

Re: combobox

Posted: Thu Jul 15, 2010 12:22 pm
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é