Keyboard Shortcuts for .NET MAUI Desktop Apps with the NEW Keyboard Accelerator Feature

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
net 8 is here and that means net Maui has a bunch of goodies built right in now I made a video recently about all the new things in net 8 for Don Maui but I wanted to give some Hands-On little quick tip tutorials on some of the features so today I'm going to be talking about one of my favorite features which is keyboard accelerators for desktop applications and we made a video previously about how to add these menus into your application you know file edit view help those type of menus up top well I'm going to show you how to add keyboard acceler so your users can easily access all of those awesome menus that you've implemented with a few keystrokes so tune [Music] in hey everyone I'm James and today we are going to introduce some new features into our D Maui application specifically for desktop and keyboard accelerator those little keyboard shortcuts that are so so Nifty so let's just go ahead and get right into it now I've already made a video on migrating your existing net Maui apps to net 8 and here we've added some new features that were introduced previously such as this contacts menu here so we have this little fly out we have open save save as under new we have a subf fly out menu here so we have new project new file new class new new all the new stuff and all these other menus here now one feature that was sort of missing that's now introduced in net 8 is keyboard accelerator so having your users simply have a keyboard shortcut you know contrl n for example might be pretty here so have to click around a whole bunch um so we're going to go ahead and introduce that into this application so I'm just going to stop debugging and here is my fly out menu here's that file the new the file class open all these things we have nice little separators all that goodness I'll link to my other video um already that shows you how to introduce these things but let's add some keyboard accelerators so on any fly out item that you want to add this to all you have to do is add another node in here so here I'm going to say menu menu fly out item. keyboard accelerators and you can as many keyboard accelerators you want but we're going to add one and there's two specific things that you want to add first is going to be the modifiers that we have here and modifiers are specifically the keyboard precursor to whatever thing you want to add so of course you could have just like an F1 for example as your key but if you want them to say alt tab or alt command alt 2 or alt three or crln or contrl P or anything right you can do that and you can see there's a none option here as well so um here we're just going to go ahead and we're going to say control and you can obviously access and add multiple modifiers we're going to add one modifier and then we're going to add a key of n so you can add any key that you want there we go control n so that is going to be our control new on this new project if I wanted to add it for new file maybe control you know F or whatever contrl C contrl NN or something you know you know here I guess you know have one key so M over here whatever these are contr o contrl s you know you can have these modifiers inside of here so here we go I'm just going to go rerun it I've added just two lines of zaml right here which is super Nifty and now we'll see when our application opens up for us if I zoom in here we can see that there's automatically the control n modifier on here for me so new project control n so that's pretty nice now if I just tap on it it's going to call the menu item clicked uh which I had in the code behind but if I just come in and just do control and on my keyboard same exact thing happens right so that's really Nifty I'm saving my users multiple key uh you know clicks on their Mouse so they can do crl n boom and you're totally good to go so this will automatically add this in there for you which is super duper nice so that way you can really add these power features to your desktop applications and D Maui now I might be saying James well what if I'm not writing it in example here what if I'm creating this in the the code behind well no problem and I always get Flack for this sometimes I'm just going to delete that modifier right there so we're back to the basics okay uh now what I'm going to do is I'm going to go into the code behind for this file here we go and in the Constructor or wherever you're creating your UI what you can do is you can uh go ahead and access it by name so I have menu item new so of course you might have created it here for example so I'm going to say menu item new Dot and you guess it keyboard accelerators and I'm just going to add one so here you can add you can remove you can do a bunch of stuff and then I'm just going to say new uh oops new keyboard accelerator um just like that and I'm going to add it in so here I can have the same exact thing I have modifiers so I can say let me just go ahead and add the keyboard modifier control and then I can go ahead and say key and I'm just going to say n just like that and now when we run our applic one more time uh what we're going to see is we're going to get the same exact functionality but I'm creating it here in the code behind so matter you want to do it in zaml or you want to create it pragmatically you're going to be all set and good to go all right our application is loading I'm on this wide screen so let's put this down we can see here contrl n again I'm just going to do crln bam just like that we are totally good to go all right there you have it keyboard accelerators AKA keyboard shortcuts for your Mai desktop applications I'll link to the previous video uh where I showed you how to do all those cool fly out menus and all those things and of course I'll put a link to the coffee sample which went through that full net ma migration from Zam and forms have a video here on the channel how I did that and it's been upgraded now to net 8 so you can take a look at the change log and see all that goodness all right that's going to do it for this video if you like these quick tips in and out stuff like that give this a thumbs up let me know what else you want to see have me cover right here on the channel I appreciate all of you for subscribing if you haven't yet Jam that subscribe button so you get up toate notifications every single time I put out a video here on my channel thank you so much for watching and of course have a good [Music] one
Info
Channel: James Montemagno
Views: 1,857
Rating: undefined out of 5
Keywords: dotnet maui, dotnet, .net maui, .net maui keyboard shortcuts, .net maui shortcuts, .net maui menu, dotnet maui menu, james montemagno, maui menus, dotnet maui menu system, keyboard accelerators
Id: jvfFWT30HyU
Channel Id: undefined
Length: 6min 21sec (381 seconds)
Published: Tue Nov 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.