Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2024-09

TMenu(Item) AutoLineReduction: help needed from Delphi users/owners

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

We've recently implemented the AutoLineReduction property for TMenu(Item). The current implementation is based upon the Delphi docs and some limited user input.
So, questions remain.

For those who have a recent Delphi installed, can you please try to answer these 2 questions (I have D7, which is, to be mild, a bit ancient).

Question 1.

Given the following Menu:
TopLevel
- ItemA
- Separator
- ItemB
- Separator
- ItemC

Given that TopLevelA.GetAutoLineRedction will return True.

Now I do: ItemB.Visible := False
Then I do: TopLevel.RethinkLines.

This will hide one of the 2 now consective separators (in our implementation it hides the second one).
So it will show as
TopLevel
- ItemA
- Separator
- ItemC

I suppose this is how Delphi works as well.

So far, so good.

Now I do: ItemB.Visible := True
Then I do: TopLevel.RethinkLines.

I implemented RethinkLines such that it will now restore the separator after ItemB, because this makes sense to me.
But I have absolutely no idea if Delphi does this as well.

Question 2

Given the following Menu:
TopLevel
- Separator
- ItemA
- Separator
- Separator
- ItemB
- Separator
- Separator
- ItemC
- Separator

And TopLevel.AutoLineReduction starts out as maManual, so all separators are visible.

Now I do: TopLevel.AutoLineReduction := maAutomatic
Then I do: TopLevel.RethinkLines

It will now show as:
- ItemA
- Separator
- ItemB
- Separator
- ItemC

This is Delphi compatible AFAIK.

Now I do: TopLevel.AutoLineReduction := maManual
Then I do: TopLevel.RethinkLines

I implemented RethinkLines so that this will set all separators Visble property to True again.
This makes sense to me, as it performs the opposite action of maAutomatic. But again, I'm not really sure this is what Delphi does in this case.

So, your (Delphi users/owners) help is appreciated.

Thanks in advance.

Bart -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20240912/b951178f/attachment.htm>

Reply by email

Werner Pamler

This is with Delphi XE 11.3 (Community Edition) (do you know that the Community Edition is free? Its license conditions (non-commercial or commercial if total revenues < 5000 $) certainly apply to FPC/Laz development):

Show quoted text 11 lines
Question 1. Given the following Menu: TopLevel - ItemA - Separator - ItemB - Separator - ItemC Given that TopLevelA.GetAutoLineRedction will return True.

TMenuItem.GetAutoLineReduction is protected. I used subclassing to verify that it is true

Show quoted text 12 lines
Now I do: ItemB.Visible := False Then I do: TopLevel.RethinkLines. This will hide one of the 2 now consective separators (in our implementation it hides the second one). So it will show as TopLevel - ItemA - Separator - ItemC I suppose this is how Delphi works as well.

Yes.

Show quoted text 6 lines
Now I do: ItemB.Visible := True Then I do: TopLevel.RethinkLines. I implemented RethinkLines such that it will now restore the separator after ItemB, because this makes sense to me. But I have absolutely no idea if Delphi does this as well.

Restores ItemB and the separator

Show quoted text 16 lines
Question 2 Given the following Menu: TopLevel - Separator - ItemA - Separator - Separator - ItemB - Separator - Separator - ItemC - Separator And TopLevel.AutoLineReduction starts out as maManual, so all separators are visible.

Yes

Show quoted text 11 lines
Now I do: TopLevel.AutoLineReduction := maAutomatic Then I do: TopLevel.RethinkLines It will now show as: - ItemA - Separator - ItemB - Separator - ItemC This is Delphi compatible AFAIK.

Hmmm... I have this code in a button. When I click on this button immediately after running the project, you are right, there are only single separators. But when I first open the menu to verify the double separators and then click on the button, nothing changes, and the double separators remain...

Show quoted text 7 lines
Now I do: TopLevel.AutoLineReduction := maManual Then I do: TopLevel.RethinkLines I implemented RethinkLines so that this will set all separators Visble property to True again. This makes sense to me, as it performs the opposite action of maAutomatic. But again, I'm not really sure this is what Delphi does in this case.

I added a second button for the maManual code. Running the program and clicking both buttons in the order of your description, nothing changes
- there are still single separators.

Reply by email

Bart
to Werner Pamler
> I suppose this is how Delphi works as well. Yes.

Thanks for confirming.

> But I have absolutely no idea if Delphi does this as well. Restores ItemB

RethinkLines did not restore ItemB, we did it on purpose before calling RethinkLines.

and the separator

So, I did it OK then in this case.

Show quoted text 21 lines
> Question 2 > And TopLevel.AutoLineReduction starts out as maManual, so all > separators are visible. Yes > Now I do: TopLevel.AutoLineReduction := maAutomatic > Then I do: TopLevel.RethinkLines > > It will now show as: > - ItemA > - Separator > - ItemB > - Separator > - ItemC > > This is Delphi compatible AFAIK. Hmmm... I have this code in a button. When I click on this button immediately after running the project, you are right, there are only single separators. But when I first open the menu to verify the double separators and then click on the button, nothing changes, and the double separators remain...

So, RethinkLines only works if the menu was never shown before? That's confusing to say the least.
It's also not what the documents suggest,

Show quoted text 6 lines
> I implemented RethinkLines so that this will set all separators Visble > property to True again. I added a second button for the maManual code. Running the program and clicking both buttons in the order of your description, nothing changes - there are still single separators.

This begs the question: what is the use of having maManual in that case. But that part of the code can easily be removed/commented out. I did implement it that way based upon a comment in the bugtracker though, so that confuses me even more.

Bart

Reply by email