Skip to main content

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

 

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

 

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.

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

 

That's the answer, thanks Chris