CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Some help with VClick (and other) events

General discussion

by magosk » 01 Nov 2013 17:21

Hi!

In a base form for my mobile web app pages, I want to write functionality to automatically intercept the OnVClick event handlers the (inherited) form has. This is so that I can perform some general processing (e.g. debug logging) before calling the original event handler. Also, I can set the RemoveMobileDelay property to True for all these without having to remember it in each case. The objects in my web app which currently has these handlers are buttons (TIWCGJQMButton or those in header/footer), listview items and navbar items. I may want to do something similar for other types of events, e.g. OnChange of selectboxes. After creation, I will typically loop through the components in the form, look for a few known component types and check if they have a handler assigned. I have the following questions:

1. What is the type of OnVClick.OnEvent (like TNotifyEvent for many standard Delphi events) and which unit is it declared in? (I cannot find this through code insight or your documentation)
2. The object passed as Sender in the above cases, does it have some useful common base class? I need to find the originating object somehow through Sender, in a list of items where I among other things have stored the original event handler.

Thanks

Magnus Oskarsson
magosk
 
Posts: 181
Joined: 07 Oct 2013 08:41

by Jorge Sousa » 01 Nov 2013 17:48

Hi

1. What is the type of OnVClick.OnEvent (like TNotifyEvent for many standard Delphi events) and which unit is it declared in? (I cannot find this through code insight or your documentation)


Is

TIWCGEvent = procedure(Sender: TObject; AParams: TStringList) of object;

declared in IWCGJQComon

2 tips:

- when you use Delphi/CBuilder inspector you can see the type when you write Button.JQButtonOptions.OnClick.OnEvent
- to know in what unit is an identifier you use Refactor + Find Unit ... (or hit Ctrl+Shit+A)

2. The object passed as Sender in the above cases, does it have some useful common base class? I need to find the originating object somehow through Sender, in a list of items where I among other things have stored the original event handler.


The Sender will always be the owner class where the event is.

For instance:

1- For Button.JQButtonOptions.OnClick - the owner will be Button.JQButtonOptions class: TIWCGJQButtonOptions

2- For Button.JQEvents.OnClick - the owner will be Button.JQEvents class: TIWCGJQEvents

So in the event handler you should you use something like this, respectively

1- Button:= (Sender as TIWCGJQButtonOpption).Button
2- Button:= (Sender as TIWCGJQEvents).Owner as TIWCGJQButton

or, for any case

i:= AParams.IndexOf('ComponentName');
Button:= AParams.Objects[i] as TIWCGJQButton;

ps: We know now that we should set Sender to the root component instance, but it's too late to change without breaking the code :/

Best Regards
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by magosk » 05 Nov 2013 11:32

Thanks, just what I needed!

/Magnus
magosk
 
Posts: 181
Joined: 07 Oct 2013 08:41


Return to General

Who is online

Users browsing this forum: No registered users and 3 guests

Contact Us.