-
Notifications
You must be signed in to change notification settings - Fork 773
657 keybinding issue when attaching it to windows with commands with canexecute methods #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Updated binding initialization to use object initializer syntax for better readability. - Enhanced logging for `source` enabled status, including checks for `source.Name`. - Added logging to indicate whether `source` is enabled or disabled after `CanExecute` check. - Implemented null checks for `source` and its `DataContext` to prevent null reference exceptions.
Enhanced ActionExecutionContext and ActionMessage classes with a new IgnoreGuard property to control guard condition checks during action execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Caliburn.Micro.Platform/ActionMessage.cs:542
- [nitpick] The log message in the 'else' branch (line 549) states 'Skipping IsEnabled source because source Name is not set', which may be misleading since the branch is executed when IgnoreGuard is true rather than when source.Name is missing. Consider updating the log message to better reflect that the availability effect is intentionally skipped due to IgnoreGuard being true.
if (!context.IgnoreGuard)
Thanks for doing this. But this PR does not close the issue. It only solves the problem when using the ActionMessage directly, not what the issue initially described. Since you can't configure the |
I agree with @Filipsi, I was initially thinking of making it a static property on the ActionMessage class but that we affect all action messages. Other thoughts was to extend the parser by using another keyword than Action to indicate that this specific method should not change the Enabled status of the control. |
I also think, that this change should not be structured as a way to "ignore guard" property. Right now, when you use the keyboard shortcut, and the guard property is set to false, the target method is still invoked. This should not be the case in my opinion, since there is no point in having the guard property in the first place when you just end up ignoring it. This should be a way to allow user to have control over whatever the |
That's a great point @Filipsi and also what I was thinking it should be, perhaps a property called Also if you want to be sure that a guard is enforced you can set |
@KasperSK Maybe naming it I think that using different keyword then It's true that enabling the |
@Filipsi I like that naming it is clear what is intended by the property. Yeah I was not sure what other Keyword it should be but Call or Invoke could work. Good point, also it would make sense to enforce the guard when not doing availability updates. I will try and make an implementation based on this discussion. |
@vb2ae I dont like that since we split on the That would make the Availability update enabled for |
Introduce a new property `SkipAvailabilityResolution` in the `Caliburn.Micro` namespace to control the skipping of availability resolution during action execution. - Added `SkipAvailabilityResolution` to `ActionExecutionContext` and replaced `IgnoreGuard`. - Updated `ActionMessage` to include the new property for bypassing availability checks. - Defined a new dependency property `SkipAvailabilityResolutionProperty` in `Message.cs` for UI element attachment. - Modified `Parser.cs` to utilize the new property when interpreting message text. These changes enhance the flexibility of action execution by allowing developers to specify when to skip availability checks.
@KasperSK added Message.SkipAvailabilityResolution to bypass guard methods in Actions
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR addresses the keybinding issue by introducing a new property to control command availability resolution and refactors code formatting for improved readability.
- Introduces the SkipAvailabilityResolution property in various ActionMessage and related classes.
- Updates context propagation and logging to respect the new property.
- Improves code style by adjusting braces formatting and dependency property registration in Message.cs.
Reviewed Changes
File | Description |
---|---|
src/Caliburn.Micro.Platform/ActionMessage.cs | Adds SkipAvailabilityResolution and updates context and logging in ToString and UpdateContext. |
src/Caliburn.Micro.Platform/Message.cs | Registers the new attached property and provides corresponding getter/setter methods. |
src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/ActionMessage.cs | Introduces SkipAvailabilityResolution in the Xamarin.Forms platform implementation. |
src/Caliburn.Micro.Platform/ActionExecutionContext.cs | Integrates SkipAvailabilityResolution into the execution context with minor formatting updates. |
src/Caliburn.Micro.Platform/Platforms/Maui/ActionMessage.cs | Introduces SkipAvailabilityResolution for the Maui platform implementation. |
src/Caliburn.Micro.Platform/Action.cs | Passes the SkipAvailabilityResolution value into the ActionExecutionContext. |
src/Caliburn.Micro.Platform/Parser.cs | Sets SkipAvailabilityResolution during the ActionMessage parsing. |
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Caliburn.Micro.Platform/ActionMessage.cs:164
- The PR description refers to an 'IgnoreGuard' property, but the code uses 'SkipAvailabilityResolution'. Consider aligning the property name for consistency.
public bool SkipAvailabilityResolution { get; set; }
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces a new bool property, SkipAvailabilityResolution (alias IgnoreGuard), across multiple classes in the Caliburn.Micro library to allow bypassing availability resolution for keybindings along with some code formatting improvements.
- Added SkipAvailabilityResolution properties to ActionMessage (in multiple platform-specific files), ActionExecutionContext, and associated updates in Message and Parser.
- Enhanced logging and formatting consistency in various methods and adjusted binding initialization.
Reviewed Changes
File | Description |
---|---|
src/Caliburn.Micro.Platform/ActionMessage.cs | Added SkipAvailabilityResolution property and updated context assignment in UpdateContext and logging in ToString. |
src/Caliburn.Micro.Platform/Message.cs | Introduced an attached property and helper methods for SkipAvailabilityResolution with some changes in naming and type handling. |
src/Caliburn.Micro.Platform/ActionExecutionContext.cs | Added SkipAvailabilityResolution property and adjusted brace formatting. |
src/Caliburn.Micro.Platform/Platforms/Maui/ActionMessage.cs | Added SkipAvailabilityResolution property. |
src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/ActionMessage.cs | Introduced SkipAvailabilityResolution property with a default value. |
src/Caliburn.Micro.Platform/Parser.cs | Updated message interpretation to include SkipAvailabilityResolution from attached property. |
src/Caliburn.Micro.Platform/Action.cs | Updated action invocation to pass SkipAvailabilityResolution from the view. |
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Caliburn.Micro.Platform/Message.cs:53
- [nitpick] Consider renaming the constant to 'SkipAvailabilityResolution' (without underscores) to match the naming conventions used elsewhere.
internal const string Skip_Availability_Resolution = "SkipAvailabilityResolution";
Doing it as a attached property on the Message class would still only enable to skip the availability resolution for all the ActionMessages. So we cannot have a single action message that does updates. The request was to be able to select whether or not to do the update for a specific event. |
This pull request introduces the
SkipAvailabilityResolution
property to theActionMessage
andActionExecutionContext
classes, and updates several files to support this new property. This change aims to provide more control over whether the availability of an action should be resolved.Key changes include:
Addition of
SkipAvailabilityResolution
Property:src/Caliburn.Micro.Platform/ActionExecutionContext.cs
: Added theSkipAvailabilityResolution
property, including getter and setter methods, and updated the class to use this property. [1] [2] [3] [4]src/Caliburn.Micro.Platform/ActionMessage.cs
: Introduced theSkipAvailabilityResolution
property and updated relevant methods to utilize this property. [1] [2] [3] [4]src/Caliburn.Micro.Platform/Platforms/Maui/ActionMessage.cs
: Added theSkipAvailabilityResolution
property to theActionMessage
class.src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/ActionMessage.cs
: Added theSkipAvailabilityResolution
property with a default value offalse
.Support for
SkipAvailabilityResolution
inMessage
Class:src/Caliburn.Micro.Platform/Message.cs
: Added theSkipAvailabilityResolution
property and methods to get and set this property, and updated theOnAttachChanged
method to handle the new property. [1] [2] [3] [4]Updates to Action Invocation and Parsing:
src/Caliburn.Micro.Platform/Action.cs
: Updated theInvoke
method to include theSkipAvailabilityResolution
property in theActionExecutionContext
.src/Caliburn.Micro.Platform/Parser.cs
: Modified theCreateMessage
method to set theSkipAvailabilityResolution
property based on the target's property value.ignoreGuard2.mp4
XAML for interaction trigger
XAML for Message.Bind syntax
closing #657