How Block ALERTKEY?

I want to know how to disable the use of ALERTKEY, PROP:ReadOnly style.
ANY tips?

You dont say if you mean Alert or ALRT but you could wrap the generated code in an

omit('***BlockAlertKey***')
Alert(KeyCode)
***BlockAlertKey***

Or inside the Case Keycode place a cycle which is like a return

Case Keycode()
OF AlertKey
  Cycle
  Post(Event:SomeEvent)
END

To truly block the alerted key(s), use the EVENT:PreAlertKey to do a CYCLE near the top of the accept handling. Then the Event:AlertKey won’t fire at all.

1 Like

Except that is not true.

You can use that technique to make behavior more natural when ALERTing keystrokes that are naturally already in use (such as up/downkeys on a listbox). But it won’t stop an ALERTKEY from happening.

An example of how PreAlertKey can be used. If you comment out the CYCLE on PreAlertKey, it doesn’t work properly.

  PROGRAM

  INCLUDE('KEYCODES.CLW')
  
   MAP
   END

Window WINDOW('Caption'),AT(,,395,224),GRAY,FONT('Microsoft Sans Serif',8)
        BUTTON('&OK'),AT(291,201,41,14),USE(?OkButton),DEFAULT
        BUTTON('&Cancel'),AT(333,201,42,14),USE(?CancelButton)
        LIST,AT(23,13,148,182),USE(?LIST1),FROM('One|Two|Three|Four|Five|Six')
    END
    
    CODE
    
    OPEN(Window)
    ?LIST1{PROP:Alrt,255} = MouseLeft
    
    ACCEPT
      CASE EVENT()
      OF EVENT:PreAlertKey
        CASE KEYCODE()
        OF MouseLeft
          CYCLE !TRY COMMENTING THIS OUT
        END  
      OF EVENT:AlertKey  
        CASE KEYCODE()
        OF MouseLeft
          0{PROP:Text} = CHOICE(?LIST1)
        END
      END         
    END
1 Like

Because the alert code could be pretty much anywhere (especially if REGISTER is used), if you’re talking about a specific control, maybe it would be simplest to clear out the alert for that control. It could be any of the array elements, so you need to process them all.

  LOOP Ndx = 1 TO 255
    IF ?MyControl{PROP:Alrt,Ndx} = MyKeyCode
      ?MyControl{PROP:Alrt,Ndx} = ''
    END
  END

This is true. EVENT:AlertKey is posting in any case (with some exceptions, for example, if a LIST having no the IMM attribute receives the WM_CHAR message). EVENT:PreAlertKey is a modal event to query whether the RTL has to perform some internal actions.

I guess, the better solution is just to make key processing conditional.

...
CASE EVENT()
OF EVENT:AlertKey
  IF <condition>
    <key_processing>
  END
  ...
END
...
1 Like