Absent Member.
Absent Member.
1161 views

Visual Cobol - WPF: KeyDown event (2 keys)

Jump to solution

Hi,

the KeyDown event with one key: if e:Key = type Key:G then... (or if e:SystemKey= type Key:LeftAlt then...)

 

works well in Visual Cobol.

 

How can i handle a key combination like LeftAlt+U in Visual Cobol?

 

 

Thanks,

 

Guenter

 

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Because the Alt key is a reserved Windows key for accessing menu items etc. you have to capture it a bit differently than the other modifier keys like Shift or Ctrl.

I found an example on MSDN and converted it to COBOL:

 

    working-storage section.
    01 AltKeyPressed condition-value value false.
    method-id Window_PreviewKeyDown.
       procedure division using by value sender as object e as type System.Windows.Input.KeyEventArgs.
              
          if AltKeyPressed
             set AltKeyPressed to false
             if (e::SystemKey = type Key::U)
                set mytextBox::Text to "Alt+U is pressed!"
             else
                set mytextBox::Text to " "
             end-if
          end-if

          if (e::SystemKey = type Key::LeftAlt)
             set AltKeyPressed to true
          end-if.
      
       end method.

View solution in original post

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

Because the Alt key is a reserved Windows key for accessing menu items etc. you have to capture it a bit differently than the other modifier keys like Shift or Ctrl.

I found an example on MSDN and converted it to COBOL:

 

    working-storage section.
    01 AltKeyPressed condition-value value false.
    method-id Window_PreviewKeyDown.
       procedure division using by value sender as object e as type System.Windows.Input.KeyEventArgs.
              
          if AltKeyPressed
             set AltKeyPressed to false
             if (e::SystemKey = type Key::U)
                set mytextBox::Text to "Alt+U is pressed!"
             else
                set mytextBox::Text to " "
             end-if
          end-if

          if (e::SystemKey = type Key::LeftAlt)
             set AltKeyPressed to true
          end-if.
      
       end method.

View solution in original post

0 Likes
Absent Member.
Absent Member.
That's the answer, thanks Chris
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.