[Linux]Set EditorGadget to readonly (and back)

Share your advanced PureBasic knowledge/code with the community.
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

[Linux]Set EditorGadget to readonly (and back)

Post by Christian »

Code updated For 5.20+

Hi!

Here is some small Code to set an EditorGadget either to ReadOnly or to make editable. Perhaps someone wants to use it:

Code: Select all

hnd = OpenWindow(0, 0, 0, 500, 500, "Set Editor Editable", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hnd
  
  EditorGadget(0, 0, 0, 500, 450)
  
  ButtonGadget(1, 140, 460, 100, 25, "Lock")
  ButtonGadget(2, 245, 460, 100, 25, "Unlock")
  
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 2
            SetGadgetAttribute(0,#PB_Editor_ReadOnly, #False )
          Case 1
            SetGadgetAttribute(0,#PB_Editor_ReadOnly, #True )
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        quit = 1
    EndSelect
    
  Until quit = 1
EndIf

End