Page 1 of 1

Combobox lostfocus problem - is this a bug?

Posted: Thu May 10, 2012 7:06 pm
by Rathinagiri
Hi

Please consider this sample.

Code: Select all

#include <hmg.ch>

Function Main
   define window sample at 0, 0 width 300 height 300 main
      define combobox one
         row 10
         col 10
         width 100
         on lostfocus do_one()
      end combobox
      define textbox two
         row 40
         col 10
         width 100
         on lostfocus do_two()
      end textbox
   end window
   sample.one.additem( 'One' )
   sample.one.additem( 'Two' )
   sample.center()
   sample.activate()
   
Return

function do_one
   if sample.one.value == 0
      sample.one.setfocus()
   endif
   return nil
   
function do_two
   if len( alltrim( sample.two.value ) ) == 0
      sample.two.setfocus()
   endif
   return nil


While running, just press <tab> and the focus will move to the second control. But, I think it should be in the first control itself. Is this a bug?

Re: Combobox lostfocus problem - is this a bug?

Posted: Thu May 10, 2012 7:37 pm
by Pablo César
Hi Mr. Rathinagiri,

It is not a bug. You have commited a little mistake in your function do_two replace this line: sample.two.setfocus() by this sample.one.setfocus(). It was backing at same place, after two would pass to combobox one.

Re: Combobox lostfocus problem - is this a bug?

Posted: Fri May 11, 2012 7:29 am
by gfilatov
rathinagiri wrote:Hi

Please consider this sample.
...
While running, just press <tab> and the focus will move to the second control. But, I think it should be in the first control itself. Is this a bug?
Hi Rathi,

No, it isn't. You should correct your function do_two as showed in the updated sample below:

Code: Select all

#include <hmg.ch>

Function Main
   define window sample at 0, 0 width 300 height 300 main
      define combobox one
         row 10
         col 10
         width 100
         on lostfocus do_one()
      end combobox
      define textbox two
         row 40
         col 10
         width 100
         on lostfocus do_two()
      end textbox
   end window
   sample.one.additem( 'One' )
   sample.one.additem( 'Two' )
   sample.center()
   sample.activate()
   
Return

function do_one
   if sample.one.value == 0
      sample.one.setfocus()
   endif
   return nil
   
function do_two
   if len( alltrim( sample.two.value ) ) == 0 .and. sample.one.value != 0
      sample.two.setfocus()
   endif
   return nil
Hope that helps :idea:

Re: Combobox lostfocus problem - is this a bug?

Posted: Fri May 11, 2012 11:36 am
by Rathinagiri
Control 'one' lostfocus is fired after control 'two' gotfocus.

Am I correct?

Re: Combobox lostfocus problem - is this a bug?

Posted: Fri May 11, 2012 3:59 pm
by Pablo César
I think so. Must be same effect Wrap (navigation thru components)