Sign in Join

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

Mailing lists / lazarus / 2020-05

TAction and Short-cut conflicts

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

R.Smith

I've been using the TActionList and TAction objects, which I think is not only making life easier, but a good design choice, and it's been working a treat.

One niggle is, when I assign a short-cut to a TAction and then assign that TAction to any of the action-enabled controls, it lists the shortcut in the conflict list, which is a false positive - it's ok with a shortcut item to conflict with itself or it's own action (impossible not to, actually).

To be precise - say I have a TAction named actCut to cut text, set the Shortcut to "Ctrl+X", then assign the action to one menu item in my TMainMenu, say mmnuCut (which is new and had no other properties changed), I then will see the following in my ShortCut conflict list (accessed via the Right-click in the Menu editor --> Shortcuts --> Resolve Shortcut conflicts):

- Resolved Conflicts: 0

- Remaining Conflicts: 1
 "Ctrl+X" in actCut conflicts with "Ctrl+X" in mmnuCut ...

What's worse, if I also assign the same Action to another menu item (which is the point of using actions) in the pop-up context menu, say puCut, I can see a three-way false-positive like this:

 "Ctrl+X" in actCut conflicts with "Ctrl+X" in mmnuCut  "Ctrl+X" in actCut conflicts with "Ctrl+X" in puCut  "Ctrl+X" in puCut conflicts with "Ctrl+X" in mmnuCut

I use many Actions and shortcuts, so now resolving any REAL conflicts becomes really hard.

So before I log a bug report, let me ask the community first:
- Is this a bug?
- Is it a feature request?
- Is it a stupidity and there is some config setting I'm missing?

Also, in the conflict list, if the window is resized, the inner panel does not - like someone forgot to swicth its Align from alTop to alClient.

-------- Technical-----------------------------
A conflict should only be positive is:
1 . The conflict is NOT between a control and its own action, 2.  The conflict is NOT with a control which uses the same action -   2.1  Unless the Shortcut does not originate from the shared Action itself.
-------------------------------------------------

Thank you kindly,
Ryan

Reply by email

Vojtěch Čihák
to R.Smith

I didn't know that Menu Editor has this feature.
I tried and my project has >160 conflicts and I can confirm what you report. I also noticed that it reports Alt+C (i.e. accelerators, when some caption is "_Cut" with underlined _C_). And the window needs better anchoring for vertical resizing (buttons should be anchored to bottom and the groupbox to buttons).  
V.
______________________________________________________________

Show quoted text 5 lines
Od: "R.Smith via lazarus" Komu: Datum: 25.05.2020 21:19 Předmět: [Lazarus] TAction and Short-cut conflicts

I've been using the TActionList and TAction objects, which I think is not only making life easier, but a good design choice, and it's been working a treat.

One niggle is, when I assign a short-cut to a TAction and then assign that TAction to any of the action-enabled controls, it lists the shortcut in the conflict list, which is a false positive - it's ok with a shortcut item to conflict with itself or it's own action (impossible not to, actually).

To be precise - say I have a TAction named actCut to cut text, set the Shortcut to "Ctrl+X", then assign the action to one menu item in my TMainMenu, say mmnuCut (which is new and had no other properties changed), I then will see the following in my ShortCut conflict list (accessed via the Right-click in the Menu editor --> Shortcuts --> Resolve Shortcut conflicts):

- Resolved Conflicts: 0

- Remaining Conflicts: 1
 "Ctrl+X" in actCut conflicts with "Ctrl+X" in mmnuCut ...

What's worse, if I also assign the same Action to another menu item (which is the point of using actions) in the pop-up context menu, say puCut, I can see a three-way false-positive like this:

 "Ctrl+X" in actCut conflicts with "Ctrl+X" in mmnuCut  "Ctrl+X" in actCut conflicts with "Ctrl+X" in puCut  "Ctrl+X" in puCut conflicts with "Ctrl+X" in mmnuCut

I use many Actions and shortcuts, so now resolving any REAL conflicts becomes really hard.

So before I log a bug report, let me ask the community first:
- Is this a bug?
- Is it a feature request?
- Is it a stupidity and there is some config setting I'm missing?

Also, in the conflict list, if the window is resized, the inner panel does not - like someone forgot to swicth its Align from alTop to alClient.

-------- Technical-----------------------------
A conflict should only be positive is:
1 . The conflict is NOT between a control and its own action, 2.  The conflict is NOT with a control which uses the same action -   2.1  Unless the Shortcut does not originate from the shared Action itself.
-------------------------------------------------

Thank you kindly,
Ryan

Reply by email

R.Smith
to Vojtěch Čihák
I also noticed that it reports Alt+C (i.e. accelerators, when some

caption is "_Cut" with underlined _C_).

V.

Indeed, I did not mention this in the initial post because of TLDR; fears (though I would in the bug report, but the jury is still out on if this is even a bug) - thank you for bringing it up.

I think if the shortcut is a in-menu-only shortcut it should still be a conflict perhaps, but the extended quirk on this is that sometimes I use items with & in the name, (Like - actCompany.Caption:='Lyle & Sons.') but I don't want it to show as a shortcut (or for it to BE a shortcut).

No problem, just escape it the usual way: actCompany.Caption:='Lyle &&
Sons.'

But now, that adds a shortcut conflict to the list also, because the shortcut analyzer does not interpret the escaping - I assume.

For anyone else wishing to test - Just create a new Form app and copy the code between ======= lines below, and paste onto your form. Then go to menu editor, on any item Right-click --> Shortcuts --> Resolve shortcut conflicts.

There are only 2 shortcuts used and they differ, so there are Zero conflicts here, but the Analyzer shows no less than 6 conflicts.

[ Note1: This code has no actual shortcuts assigned to any Menu-Item. Only the TActions have shortcuts, and they differ. ] [ Note2: Shortcuts 16458 & 16459 are not special, they're simply "Ctrl+J" & "Ctrl+K", chosen arbitrarily.]

==================================

object ActionList1: TActionList
  left = 85
  top = 112
  object Action1: TAction
    Caption = 'Action1'
    ShortCut = 16458
  end
  object Action2: TAction
    Caption = 'Jack && Jill'
    ShortCut = 16459
  end
end
object pu1: TPopupMenu
  left = 32
  top = 64
  object MenuItem1: TMenuItem
    Action = Action1
  end
  object MenuItem2: TMenuItem
    Action = Action2
  end
end
object pu2: TPopupMenu
  left = 152
  top = 64
  object MenuItem3: TMenuItem
    Action = Action1
  end
  object MenuItem4: TMenuItem
    Action = Action2
  end
end

=========================

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200525/a8036fdc/attachment.html>

Reply by email