Answer the question
In order to leave comments, you need to log in
How to transfer pressing hotkeys to a separate class?
Application in C# + WPF
In one window, I have a method that handles pressing hotkeys. In this case, I use the "Tilda" key.
I would not like to have methods for processing all keys for each window, but to make a general class that would process all hotkeys for all windows of the application
How to transfer the hotkey methods to a separate class?
QuestWindow.xaml:
<Window x:Class="ToolkitsNew.QuestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ToolkitsNew"
mc:Ignorable="d"
Closing="CloseQuestionWindow"
Icon="images/icons/icon without logo.ico"
Background="#535353"
Topmost="True"
KeyDown="ShowPreviewCard"
Title="Card Editor"
WindowStartupLocation="CenterScreen"
Height="500"
Width="734">
private void ShowPreviewCard(object sender, KeyEventArgs e)
{
if (e.Key == Key.OemTilde)
{
e.Handled = true;
if (keyTilde == 0)
{
window.Topmost = true;
window.cardText.Text = questionTextBox.Text;
window.cardBorder.Visibility = Visibility.Visible;
keyTilde = 1;
}
else if (keyTilde == 1)
{
window.cardText.Text = answerTextBox.Text;
keyTilde = 2;
}
else if (keyTilde == 2)
{
window.cardBorder.Visibility = Visibility.Hidden;
keyTilde = 0;
this.Visibility = Visibility.Visible;
window.Topmost = false;
}
}
}
Answer the question
In order to leave comments, you need to log in
what you have cartWrapper
is a collection of NodeList elements that does not have the querySelector method you are trying to call on that lineempty = cartWrapper.querySelector('.empty');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question