TControl:Hide() and TDialog Activation

TControl:Hide() and TDialog Activation

Postby xProgrammer » Sun Jul 27, 2008 11:21 pm

Hi Antonio

TControl:Hide() works but only if you call it after the TDialog has been activated. I wanted to include some TButtons that were hidden from the start. Is there a way of doing this?

As a reasonable workaround I figured I could call a function to hide these buttons when the TDialog was activated (like an ONINIT option). However I discovered that whilst TControl has a bInit DATA, the bInit code block is not called on Activation but is called on the resize event. This may mean that it would be called if the TDialog was activated MAXIMISED or CENTERED - I haven't tested for that. It isn't called if the TDialog is merely activated. There is code so that bInit can only be called once so I presume it was intended to be called when the TDialog is activated.

I did get things going by adding a bStartUp DATA and inserting the following code into TDialog:Activate() after ::Show() and before ::WinRun()

Code: Select all  Expand view  RUN
IF ::bStartUp != nil
   EVAL( ::bStartUp )
ENDIF


I haven't included code to reset bInit to nil because I figure that TDialog:Activate() will only get called once. I'm not sure if transferring bInit to this place in the code is a perfect solution to ensuring that the initialisation code block is run - depending upon what are the consequences of having initialisation code before WinRun(). (That assumes that the RESIZE event fires after or during WinRun() and not before - something I haven't tested.) But you might want to look into the best way of having TDialog initialisation code firing however the TDialog is activated.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Sun Jul 27, 2008 11:33 pm

Doug,

Your solution is fine, though I would suggest to evaluate it before the ::Show() call, so if a control is going to be hidden, it will not be seen.

Also I would propose to use DATA bInit instead of bStartUp, so we use a compatible syntax.

Self should be provided as a parameter, so we get full access to the dialog object:
Code: Select all  Expand view  RUN
METHOD Activate( ... ) CLASS TDialog

   ...

   if ValType( ::bInit ) == "B"
      Eval( ::bInit, Self )
   endif

   ::Show()

   ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xProgrammer » Mon Jul 28, 2008 4:08 am

Hi Antonio

It didn't work.

The main problem is that TControl:Hide() only seems to work after TDialog:Show().

Second issue seems to relate to TDialog:bInit. I was setting it manually to a code block with code like this:

Code: Select all  Expand view  RUN
dlg_CALENDAR:bInit := { | | ::HideButtons() }


However TDialog:Activate takes a bInit parameter (parameter 6) and then executes the following:

Code: Select all  Expand view  RUN
::bInit     = bInit


This, of course, overwrites any bInit that has been set manually. So I switched to setting bInit by the ON INIT option of the ACTIVATE DIALOG command. But it might be nicer to have:

Code: Select all  Expand view  RUN
IF ValType( bInit ) == "B"
   ::bInit = bInit
ENDIF
so it can be set manually.

But because of issue 1 it still didn't work.

So for the time being I have reverted to using bInit but have changed the point in the code at which it is evaluated to after Show(). It would of course be nicer to find a way of hiding them before Show() is called but Hide() just doesn't do it.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby nageswaragunupudi » Mon Jul 28, 2008 8:05 am

At the outset let me confess that I do not know anything about Linux and obviously I never worked with FiveLinux.

But in Windows, ACTIVATE DIALOG ON INIT oBtn:Hide() works well and thats what I do. Does it mean this does not work in FiveLinux ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby xProgrammer » Mon Jul 28, 2008 8:50 am

Hi NageswaraRao

Correct. ON INIT oBtn:Hide() doesn't work under FiveLinux unless you make changes to the TDialog class so that TDialog:bInit is evaluated after the ::Show() in TDialog:Activate().

There are two reasons for this. Unaltered the ON INIT didn't seem to fire, but regardlesss oBtn:Hide() only hides the button after TDialog:Show() has been called by TDialog:Activate(). If called before then there is no error per se but the oBtn is visible (ie not hidden). This may be because Hide() can't work with a widget before it has been Shown() or perhaps more likely that the TDialog:Show() function is reversing what Hide() does.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 0 guests

cron