Board index » cppbuilder » Control doesn't have needed get/lose focus events

Control doesn't have needed get/lose focus events

Quote
"Randall Parker" <rgpar...@west.net> wrote in message

news:MPG.1884e4fc52deb10498978b@forums.inprise.com...

Quote
> If a control inherits from another control doesn't it inherit
> all of that control's events?

Yes

Quote
> If a control inherits from TWinControl shouldn't it have
> the On Enter and On Exit events?

Yes.  However keep in mind that those events are declared as protected in
TWinControl itself.  So, if you're deriving your control from TWinControl
directly, then you have to manually promote the events yourself to published
if you want them to appear in the Object Inspector.  The same applies if you
derive your control from some other class which doesn't already publish the
inherited events you want to use.

Quote
> So shouldn't OnEnter and OnExit show up in the C++ Builder designer
> when I drop a TiXYPlot control on a form and then look at the event
> list for that control?

Only if TiComponent, TiVCLComponent, TiPlotComponent, or TiXYPlot
explitically promote those events to published, which it sounds like they
aren't.  TWinControl and TCustomControl are base classes, they leave the
events as protected.

Quote
> Can I compensate for that lack of OnEnter and OnExit by creating my own
class
> that inherits from TWinControl (or some other more suitable Borland
control)
> and then make my class instantiate the TiXYPlot with my class as its
parent and
> then put my class on the form instead?

Perhaps, but an easier way would be to simply derive your class from
TiXYPlot directly and then promote the inherited events to published:

    class TMyXYPlot : public TiXYPlot
    {
    __published:
        __property OnEnter;
        __property OnExit;
    };

Then, just put your TMyXYPlot class into a package, register it with the
Component Palette, and you'll be able to drop it onto the form instead of
using TiXYPlot.  That way, you can use your TMyXYPlot class exactly as you
would normally use TiXYPlot, but you then get the OnEnter and OnExit events
in the Object Inspector as well as everything else TiXYPlot already exposes.

Gambit

 

Re:Control doesn't have needed get/lose focus events


TiComponent is derived from TCustomControl.  TCustomControl implements the
properties of TWinControl, but doesn't publish all of them.  So, the component
author only published some of the TControl (base) properites.  BTW, the
TCustom????? classes are specifically for this purpose... 'stub' classes from which
to derive new custom classes, allowing the component author to publish only the
properties desired (to be available to the component user), while leaving the
remainder protected.

Re:Control doesn't have needed get/lose focus events


meant TWinControl  in both cases

Re:Control doesn't have needed get/lose focus events


Hello Randall,

The events are inherited, but the component developer can choose to expose
or to not expose those events as needed.  Since we also distribute our VCL
components in ActiveX binary form, we don't always expose some
events/properties/methods, especially those that are Delphi/C++ Builder
only.  We will gladly go ahead and add those two events to our Plot
Components on the next update of our version 3.x product.

You can easily add these two events to the component by adding the following
two lines just before the implementation and right after the existing
properties in our "iPlotComponent.pas" source code file (usually located in
"C:\Iocomp\Product\CBuilder5",  "C:\Iocomp\Product\CBuilder6", or whatever
version of C++ Builder you are using)...
=====================
.....etc...
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnEnter; //Expose Event Here
    property OnExit; //Expose Event Here
  end;

implementation

type
  TiPlotObjectAccess        = class(TiPlotObject       ) end;
....etc...
====================
...and then rebuild the Iocomp component package.  The  OnGotFocusXXX events
are for the sub-objects of the component (such as axes, annotations,
toolbar, legend, channels, limits, etc.).  They are not actually component
descendents of TWinControl, but are our own internal "components" which have
their own event structure.  Only the overall component inherits from
TWinControl in the VCL version of the component and from TWidgetControl in
the CLX version of the component.

Let us know if this helps or if you need any other information or
assistance.

P.S. we recommend only using the TiXYPlot component if you have data that
doesn't satisfy the function y=f(x).  We recommend using TiPlot for most
graphs as that component has special speed enhancements that TiXYPlot
doesn't have, as well as support for additional features.

Cheers,
Patrick Carroll
Iocomp Software
http://www.iocomp.com

Quote
"Randall Parker" <rgpar...@west.net> wrote in message

news:MPG.1884e4fc52deb10498978b@forums.inprise.com...
Quote
> I've been away from using C++ Builder for a couple of years but have a new
> project that I'm doing on it. I'm kinda rusty.

> If a control inherits from another control doesn't it inherit all of that
> control's events? If a control inherits from TWinControl shouldn't it have
the
> On Enter and On Exit events?

> I'm looking at the hierarchy of a class called TiXYPlot (from a third
party
> graphics library from IOComp - see http://www.iocomp.com for the library).
The
> inheritance hierarchy shows TWinControl in its inheritance hierarchy
followed
> by TCustomControl, TiComponent, TiVCLComponent/TiCLXComponent and
> TiPlotComponent.

> So shouldn't OnEnter and OnExit show up in the C++ Builder designer when I
drop
> a TiXYPlot control on a form and then look at the event list for that
control?

> Instead of OnEnter and OnExit I see a bunch of OnGotFocusXXX and
OnLostFocusXXX
> methods but they all refer to objects within the control and there is no
> control-level getting and losing focus pair of events.

> Can I compensate for that lack of OnEnter and OnExit by creating my own
class
> that inherits from TWinControl (or some other more suitable Borland
control)
> and then make my class instantiate the TiXYPlot with my class as its
parent and
> then put my class on the form instead?

Other Threads