Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TButton - click behaviour when change style


This question is answered.


Permlink Replies: 4 - Last Post: Apr 23, 2015 5:07 AM Last Post By: André Diel
Mark Gorst

Posts: 23
Registered: 6/7/02
TButton - click behaviour when change style  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 22, 2015 8:45 AM
Successfully wrote my first App (longtime VCL, first time FM). Then decided to change the TButton style. I wanted to set the colour and so added a TRectangle as a custom button style.

What I found was that the TButton doesn't "work" any more. I thought I'd lost the Click event but making the rectangle smaller than the button I found that I get a TButton.OnClick() on the button part, but not on the part where the TRectangle has been added to the style ?

I wrote a very quick FM running under windows as this can be shown to happen in the simplest case. This didn't seem right ? If so what's the quick way to get the TRectangle part of the style to behave the same way as the rest of the TButton style ?

(XE7)

Thanks
André Diel

Posts: 27
Registered: 7/28/07
Re: TButton - click behaviour when change style
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 22, 2015 10:26 AM   in response to: Mark Gorst in response to: Mark Gorst
If I understood your situation,
You can try set the property HitTest of the rectangle to false.
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: TButton - click behaviour when change style
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 22, 2015 11:39 AM   in response to: Mark Gorst in response to: Mark Gorst
Mark Gorst wrote:
Successfully wrote my first App (longtime VCL, first time FM). Then decided to change the TButton style. I wanted to set the colour and so added a TRectangle as a custom button style.

What I found was that the TButton doesn't "work" any more. I thought I'd lost the Click event but making the rectangle smaller than the button I found that I get a TButton.OnClick() on the button part, but not on the part where the TRectangle has been added to the style ?

I wrote a very quick FM running under windows as this can be shown to happen in the simplest case. This didn't seem right ? If so what's the quick way to get the TRectangle part of the style to behave the same way as the rest of the TButton style ?

(XE7)

Thanks

HitTest is the issue here

I found that I had to change how I thought about apps ... stop thinking in terms of controls (ie TWinControl) and consider a "picture" with layers that can respond or not ... that's probably not clear yet but when you get it that may help
--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Mark Gorst

Posts: 23
Registered: 6/7/02
Re: TButton - click behaviour when change style  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 1:24 AM   in response to: Linden ROTH in response to: Linden ROTH
Linden ROTH wrote:
Mark Gorst wrote:
Successfully wrote my first App (longtime VCL, first time FM). Then decided to change the TButton style. I wanted to set the colour and so added a TRectangle as a custom button style.

What I found was that the TButton doesn't "work" any more. I thought I'd lost the Click event but making the rectangle smaller than the button I found that I get a TButton.OnClick() on the button part, but not on the part where the TRectangle has been added to the style ?

I wrote a very quick FM running under windows as this can be shown to happen in the simplest case. This didn't seem right ? If so what's the quick way to get the TRectangle part of the style to behave the same way as the rest of the TButton style ?

(XE7)

Thanks

HitTest is the issue here

I found that I had to change how I thought about apps ... stop thinking in terms of controls (ie TWinControl) and consider a "picture" with layers that can respond or not ... that's probably not clear yet but when you get it that may help
--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Thanks. I tried to mark this as correct as well, but turns out only one can be correct, so you'll just have to settle for helpful.

Anyway that sorted my problem. I had considered "HitTest" but my logic was reversed from VCL thinking that you did want to "hit" the rectangle as it was part of the TButton.

This does beg the question as to what governs the "hit" area. Is it that the "background" is the maximum area that can be "hit" ?

I'm assuming that's true, but if not, if I decided to add an TRectangle that enclosed the TButton (i.e. bigger than the background) - and I wanted that to be "senstitive" as well, could I get it to generate a click event. Other than set "HitTest" to true, how could I get it to handle/generate a click event ?

André Diel

Posts: 27
Registered: 7/28/07
Re: TButton - click behaviour when change style
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 5:07 AM   in response to: Mark Gorst in response to: Mark Gorst
My English is not very good, and the Google translator tool does not help me as expected. [laughs].

"HitTest" defini se o componente receberá o "hit". Caso falso, o "hit" vai para o próximo componente e assim por diante até encontrar algo que receba o "hit".

If the button is inside the rectangle, you don't need change the "HitTest" property of the rectangle, and you can choose the rectangle onclick event the onClick event of the button.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02