[Gambas-user] Stopping an event when user clicks on the form menu

Fabien Bodard gambas.fr at ...626...
Sat Jan 25 21:19:09 CET 2014


2014-01-25 Bruce <bbruen at ...2308...>:
> On Fri, 2014-01-24 at 16:21 +0100, Fabien Bodard wrote:
>> http://gambasdoc.org/help/comp/gb.qt4/application/activecontrol?v3
>>
>> Returns the control having the focus.
>>
>> But return null for a menu or when the form lose the focus
>>
>
> Thanks Fabien, that's what I needed...
>
> ... but it's strange, no matter how long I stare at that link, I just
> can't see that second line   :-)
>
>
>
> Uhoh :-( spoke too soon.  Just before I sent this, I had another
> thought.  Yep, I had fooled myself into thinking it was that simple.
> Attached is a quickly mocked up demo of what's driving me nuts.
>
> The use scenario is this:
> 1) If the user is just going to do stuff within the form, then they must
> enter something into the "Must complete" box, then they can tab or click
> anywhere else and do what they want.
> 2) But they can also do stuff in the File menu, load,save,new or exit.
> This now works thanks to your input. What is there is some Dialogs and
> some Message commands (and just Me.Close).
> 3) Or perhaps they want to change some program option. They should be
> able to go Tools|Options which opens a form to change them. Guess what
> happens!
> 4) Or perhaps they want to view the help files. (This one is "fake" it's
> just there to demonstrate something). So they should be able to go Help|
> Browse Help.
>
> IOW 2,3,or 4) need to be able to occur without invoking the error
> balloon.
>
> Re: 4) this just uses an InputBox to demonstrate the same problem.
>
> Any further ideas?

yes :

Public Sub txtMandatory_LostFocus()


 If Not Application.ActiveControl Or If
Application.ActiveControl.Window <> Me.Window Then Return

 If Not txtMandatory.Text Or If txtMandatory.Text = "<new>" Then

   Balloon.Error("this must be filled before anything else", Last)
   txtMandatory.Select()
   Last.SetFocus

 Endif


End


So if the control is known then if the control is not in the same
window then do nothing.

:-)



> Bruce
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard




More information about the User mailing list