Recent

Author Topic: RadioGroup problems  (Read 501 times)

bobonwhidbey

  • Sr. Member
  • ****
  • Posts: 376
    • Double Dummy Solver - free download
RadioGroup problems
« on: June 29, 2019, 06:27:52 pm »
The recent thread on tRadioGroup spurred me to test the use of various events. Of course ONClick works well but I could not get many of the other events to fire; e.g. OnDblClick, OnMouse(anything), OnEnter, etc. Moreover, I couldn't get ShowHint to view when my mouse hovered over the control. Are these features to be added later or is there some workaround?
Win10 64-bit / Lazarus 32-bit 2.0.6 / FPC 3.0.4

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #1 on: June 29, 2019, 06:45:22 pm »
I have no idea what you are doing wrong, I just dropped a RadioGroup on the form and assigned the
events, they all work... Enter.Exit, MouseEnter, MouseLeave , DoubleClick etc...
Number 1 at blue screen app creations!

lucamar

  • Hero Member
  • *****
  • Posts: 2137
Re: RadioGroup problems
« Reply #2 on: June 29, 2019, 06:52:08 pm »
I did a (small) test on LInux and (at least) these work:
OnClick
OnEnter
OnExit
OnKeyDown/Up/ Press
OnMouseEnter/Leave/Move
OnUTF8KeyPress
OnDblClick is the only one which failed
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

bobonwhidbey

  • Sr. Member
  • ****
  • Posts: 376
    • Double Dummy Solver - free download
Re: RadioGroup problems
« Reply #3 on: June 29, 2019, 07:01:21 pm »
I've created an OnDblClick event and it's not ever executed on a double click. The same approach was used to test the other events.

Code: Pascal  [Select]
  1.   TForm1 = class(TForm)
  2.     Label1: TLabel;
  3.     RadioGroup1: TRadioGroup;
  4.     procedure RadioGroup1DblClick(Sender: TObject);
  5.   private
  6.  
  7.   public
  8.  
  9.   end;
  10.  
  11. var
  12.   Form1: TForm1;
  13.  
  14. implementation
  15.  
  16. {$R *.lfm}
  17.  
  18. { TForm1 }
  19.  
  20. procedure TForm1.RadioGroup1DblClick(Sender: TObject);
  21. begin
  22.   Label1.Caption := 'Dbl';
  23. end;
  24.  
  25. end.  
Win10 64-bit / Lazarus 32-bit 2.0.6 / FPC 3.0.4

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #4 on: June 29, 2019, 07:20:31 pm »
Well I am running 2.0.2 on windows, maybe you should upgrade?
Number 1 at blue screen app creations!

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #5 on: June 29, 2019, 07:43:15 pm »
I just added some items to the box and the items themselves actually call the ENTER,EXIT, MouseEnter
and mouseleave too...

 The double click does not work on the items but do work if you click in the non item area.

 This is kind of messed up because there is no way to tell if the events are working with the main base of
the Radio Control or Items themselves..
I really don't think they should be getting triggered on the items, just the box itself...
Number 1 at blue screen app creations!

bobonwhidbey

  • Sr. Member
  • ****
  • Posts: 376
    • Double Dummy Solver - free download
Re: RadioGroup problems
« Reply #6 on: June 29, 2019, 07:52:06 pm »
I upgraded to 2.0.2 and I see that the ShowHint seems to be working better, but the component still doesn't act the way I expected it to act.

When you CLICK on a button or the name of the button (entered in the Item list), the button is turned on and the OnClick event is fired. Good.

When you DOUBLECLICK on a button or the name of the button (entered in the Item list), the button is turned on but the OnDblClick event is NOT fired. Not what I would have expected.  The only way to fire that event is to double-click somewhere in the component that's not on a button or name.

Conversely, the OnClick event is NOT fired unless you click on a button on name...just the opposite of the onDoubleClick.
« Last Edit: June 29, 2019, 07:56:24 pm by bobonwhidbey »
Win10 64-bit / Lazarus 32-bit 2.0.6 / FPC 3.0.4

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #7 on: June 29, 2019, 08:05:24 pm »
Those events are not suppose to fire for the items but through them...

The fact the OnEnter and OnExit along with the OnMouserEnter and OnMouseExit is firing when going
from one item to another is WONG!

Those events are only suppose to fire when in/out of the main Group box..

Only the OnClick and OnSelectionChanged is to fired when clicking on the items.
Onclick always and OnSelectionChanged only when the selection actually changes//

I would say this is kind of messed up... I've never used these events in that control so I don't know
when this started.

 My Delphi install behaves correctly.. \
Number 1 at blue screen app creations!

bobonwhidbey

  • Sr. Member
  • ****
  • Posts: 376
    • Double Dummy Solver - free download
Re: RadioGroup problems
« Reply #8 on: June 29, 2019, 08:32:29 pm »
A problem for me is that the OnClick event does not fire when you click on an item that is already selected. i.e. if you click on the first item, and that item has already been selected, the OnClick does not fire. I would like to change the ItemIndex to -1 upon clicking a button that is already selected.

I believe this component's name, and it's usage, were patterned after the old car push-button radios. In many of those radios you could push a button that was already down and get it to pop up. Even though the station wouldn't change, all the buttons would be up.

Fast forward 50 years or so to our Tradiobutton component. I think it would be nice to indicate "none of the above" as a choice in the tradiogroup without actually spelling out that option in another Item.  If no button is lit then it is visually clear that you have not selected one of the items. Seems like a good option to me. Perhaps such a "feature" should be allowed via a property.
Win10 64-bit / Lazarus 32-bit 2.0.6 / FPC 3.0.4

lucamar

  • Hero Member
  • *****
  • Posts: 2137
Re: RadioGroup problems
« Reply #9 on: June 29, 2019, 08:44:03 pm »
I think the problem is that all these "standard" controls are basically "wrappers" around the corresponding widget in the widgetset, so their behaviour (and appearance) depends on the undelying OS/WM. Thus you have controls that behave somewhat differently in the various widgetsets.

It's part of the price you pay for multi-platform programming, I suppose.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #10 on: June 29, 2019, 09:32:22 pm »
Well I just checked my old Delphi and guess what?, the OnClick does not fire at all on anything condition..

must of  been an oversite at release time... >:(

But all is not lost, you can use the OnMouseUp event for that.... In that event you then test the
itemIndex etc...

  if you want to make it a little more intelligent you can check the current control under the cursor at that
moment to determine which one it was that got clicked.
 If you need example Code I can provide it.


Number 1 at blue screen app creations!

lucamar

  • Hero Member
  • *****
  • Posts: 2137
Re: RadioGroup problems
« Reply #11 on: June 29, 2019, 09:52:56 pm »
In that tesiture it might be better to just use a TGroupBox and add some TRadioButtons to it. Embed all in a frame for ease of use, implement whatever behaviour you want and you're done. :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

jamie

  • Hero Member
  • *****
  • Posts: 2159
Re: RadioGroup problems
« Reply #12 on: June 30, 2019, 07:09:35 pm »
After spending some time viewing the source code to the TRadioGroup, I honestly believe all the hacking
that has been taking place in it should be retracted..

  It is a total mess in there! And I am not making an over statement about it ether..

 There are several places where attempts are made to circumvent any repeating clicking so if you
correct the code in place where the most logical place would be to do it, it makes no difference because all of
the other places where it's doing it to null any clicking on an item that is already in place..

 I found the logic place to this and it is a total mess with comments about being DELPHI compliant. I don't
remeber Delphi ever being this bad!

  What really gets  me is there does not seem to be anyone complaining about it?

  So do we have two additions of Lazarus out there? One that Works for those who wants it to work and one
for any one else that shouldn't be allowed to generate clean code?

 I have started a note book of source file patches now to fix Lazarus each time I upgrade because it seems
all the reporting I've done in the past here and on the bug site goes no where. I've also included source code
snippets and locations where the issue is located.. But no results..

 I am getting ready to purchase The latest Delphi, maybe this is what it's really all about!
Number 1 at blue screen app creations!