Recent

Author Topic: Calling eventhandler by clicking anywhere inside frame  (Read 2594 times)

kapibara

  • Hero Member
  • *****
  • Posts: 610
Calling eventhandler by clicking anywhere inside frame
« on: April 01, 2016, 03:12:40 am »
Lets say I have a TFrame with a few panels and some smaller controls. Now I want to click anywhere inside the frame, even on a child control, and have always the same event reacting and say: "Clicked!". (In reality, assign the frame to a CurrentFrame variable so I know what frame instance is selected)

Is it necessary to assign the eventhandler to each and every control inside the frame, or is there another way to solve this?
« Last Edit: April 01, 2016, 03:31:21 am by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

balazsszekely

  • Guest
Re: Calling eventhandler by clicking anywhere inside frame
« Reply #1 on: April 01, 2016, 05:39:16 am »
Select all components on the frame, then create the event. This way you will have a single OnClick. I don't see why this should be a problem?  Another windows only solution is to hook the mouse.

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: Calling eventhandler by clicking anywhere inside frame
« Reply #2 on: April 01, 2016, 09:39:12 pm »
Thanks, I missed the obvious.  ;D

I was focused on stuff like keypreview which doesn't look for mouseclicks and that got me confused.
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

 

TinyPortal © 2005-2018