microsoft / Dynamics365Commerce.Solutions

Repository for hosting the Dynamics 365 Commerce end to end sample solutions
Other
54 stars 26 forks source link

NumPad support with CustomViewControllerBase #182

Open ax365 opened 1 year ago

ax365 commented 1 year ago

Extensibility request:

Provide support for adding NumPad and INumPadInputBroker to custom pos -views- that extend from CustomViewControllerBase. Similar to how custom pos -dialogs- extend from ExtensionTemplatedDialogBase and thus get the NumPad and INumPadInputBroker brokers “for free” (without requiring extension code to initialize it).


Context:

In the legacy RetailSDK, when creating custom views, we extended the ExtensionViewControllerBase abstract class. With the introduction of the CommerceSDK, ExtensionViewControllerBase is now deprecated.

This deprecated abstract class ExtensionViewControllerBase had some useful properties:

With the new CommerceSDK, the requirement is to extend CustomViewControllerBase abstract class instead.


The official sample extension on GitHub for the InStore.BarcodeMsrDialogSample utilizes IAlphanumericNumPad but this is for a -dialog- (not a -view-).


As a potential workaround, I've attempted the following:

Implement INumPadInputSubscriberEndpoint: image

Instantiate the broker from the subscriber: image

Initialize options and bind the NumPad: image


The workaround described above allows the NumPad to render on the custom view. But it's still not behaving fully as intended.

Below describes the main issue:

The screenshot below has been taken immediately upon loading of the custom view. And I’m typing on the keyboard but none of the digits are rendering on the NumPad (it doesn’t recognize it). image

Because of that, as a test, I decided to click the NumPad “input bar” – you can see the dotted lines: image

Now when I enter keyboard input, the digits show up: image

^ If I “click out” of the input bar (no more dotted lines) – then it goes back to the first screenshot behaviour (it does not recognize/update keyboard input).


lukedgr commented 11 months ago

Hi ax365, thank you for providing all of details and screenshots. I see that the CustomViewController implements the INumPadInputSubscriberEndpoint interface by declaring the implementsINumPadInputSubscriberEndpoint field. Can you please confirm that this field is initialized and set to true in the view's constructor? I did not see that initialization in the code snippets provided. Thanks!

ax365 commented 11 months ago

Thank you lukedgr,

Initializing implementsINumPadInputSubscriberEndpoint in the constructor has now resolved this issue. Now upon loading of the custom view, the NumPad will immediately respond to keyboard input.

image

ax365 commented 1 month ago

Hi @lukedgr,

Two follow-up questions related to this: