From: Art H. <art...@ar...> - 2012-08-21 01:43:27
|
Is there an example showing how to do some processing when an input field looses focus? I am especially interested in an Edit input field loosing focus. Thanks Art Heimsoth |
From: Mark M. <mie...@gm...> - 2012-08-21 02:38:39
|
On Mon, Aug 20, 2012 at 6:43 PM, Art Heimsoth <art...@ar...> wrote: > Is there an example showing how to do some processing when > an input field looses focus? I am especially interested in an Edit > input field loosing focus. Thanks Here is a snippet of code: ::method initDialog expose staticText staticText = self~newStatic(IDC_ST_TYPE) self~connectEditEvent(IDC_EDIT, GOTFOCUS, "onFocus") self~connectEditEvent(IDC_EDIT, LOSTFOCUS, "onLostFocus") ::method onFocus unguarded expose staticText staticText~setText("The edit control now has the focus") return 0 ::method onLostFocus unguarded expose staticText staticText~setText("The edit control does not have the focus") return 0 In the above dialog, I change the text of a static control to show when the edit control gets the focus and when it losses the focus A couple of points. * You don't *have* to connect both the got focus and lose focus events if you are only interested in the lost focus. You can just connect the LOSTFOCUS event. * Technically, the program probably did not need to return 0 from the 2 event handlers. But, it is a good habit to always return a value from an event handler. I'll write an example and add it to the Extra ooDialog Examples package. What type of processing are you thinking of doing? -- Mark Miesfeld |
From: Art H. <art...@ar...> - 2012-08-21 03:08:04
|
> On Mon, Aug 20, 2012 at 6:43 PM, Art Heimsoth > <art...@ar...> wrote: > >> Is there an example showing how to do some processing when an >> input field looses focus? I am especially interested in an Edit >> input field loosing focus. Thanks >> > > Here is a snippet of code: > > ::method initDialog > expose staticText > > staticText = self~newStatic(IDC_ST_TYPE) > > self~connectEditEvent(IDC_EDIT, GOTFOCUS, "onFocus") > self~connectEditEvent(IDC_EDIT, LOSTFOCUS, "onLostFocus") > > ::method onFocus unguarded > expose staticText > staticText~setText("The edit control now has the focus") > return 0 > > ::method onLostFocus unguarded > expose staticText > staticText~setText("The edit control does not have the focus") > return 0 > > In the above dialog, I change the text of a static control to show > when the edit control gets the focus and when it losses the focus > > A couple of points. > > * You don't *have* to connect both the got focus and lose focus > events if you are only interested in the lost focus. You can just > connect the LOSTFOCUS event. > > * Technically, the program probably did not need to return 0 from > the 2 event handlers. But, it is a good habit to always return a > value from an event handler. > > I'll write an example and add it to the Extra ooDialog Examples > package. What type of processing are you thinking of doing? > > -- > Mark Miesfeld > Thanks, I have an entry panel to handle the purchase of seed received from trucks. On the panel are several input fields, the gross weight, the empty weight and then how to divide up the load - by percentage or weight for different buyers. When the gross weight AND the empty weight is entered, I then also display the net weight, so if the operator is wanting to divide up the load by poundage, they have a basis to work from. When the divided up weight is selected, I give an entry line for the buyer's information that will receive that portion. If the percentage is not 100%, when that field is entered, or the poundage is not all of the net weight, then I present another entry line for another buyer. Thanks for pointing me to the onCode to use with the EditEvent. I thought I had looked for that, but apparently did not look close enough as I found it quite easily now. -- Art Heimsoth - art...@ar... |