Combobox lostfocus problem - is this a bug?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Combobox lostfocus problem - is this a bug?

Post 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?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Combobox lostfocus problem - is this a bug?

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Combobox lostfocus problem - is this a bug?

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Combobox lostfocus problem - is this a bug?

Post by Rathinagiri »

Control 'one' lostfocus is fired after control 'two' gotfocus.

Am I correct?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Combobox lostfocus problem - is this a bug?

Post by Pablo César »

I think so. Must be same effect Wrap (navigation thru components)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply