Object.Lock

Post Reply
User avatar
cogier
Site Admin
Posts: 102
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Object.Lock

Post by cogier » Monday 12th June 2017 11:19am

Does anybody have any example code using Object.Lock and Object.Unlock? I have tried all sorts of combinations but can't get anything to work.

User avatar
jornmo
Site Admin
Posts: 120
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Object.Lock

Post by jornmo » Monday 12th June 2017 8:34pm

The QT4 RichText editor example had a good display of this (long time since I read it). It enables you to freeze an object/control, i.e. hinder it from raising events while carrying out other tasks. In that example it was about setting format and updating tool button's status while typing if I remember correctly.

User avatar
jornmo
Site Admin
Posts: 120
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Object.Lock

Post by jornmo » Monday 12th June 2017 8:35pm

OK... I am tired and am writing poorly... sorry :?

vuott
Posts: 3
Joined: Wednesday 05th April 2017 6:07pm

Re: Object.Lock

Post by vuott » Monday 12th June 2017 9:29pm

cogier wrote:
Monday 12th June 2017 11:19am
Does anybody have any example code using Object.Lock and Object.Unlock?
Just a little and simple example:

Code: Select all

Public Sub ToggleButton1_Click()

  If ToggleButton1.Value Then
    Object.Lock(Button1)
    ToggleButton1.Text = "Now Button1's locked !"    ' Button1 click event will not be raised !
  Else
    Object.Unlock(Button1)
    ToggleButton1.Text = "Now Button1's unlocked !"  ' Button1 click event will be raised !
  Endif
  
End


Public Sub Button1_Click()

  Print "Sum liber !"

End

User avatar
cogier
Site Admin
Posts: 102
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Object.Lock

Post by cogier » Tuesday 13th June 2017 10:58am

Thanks both.

My error was to think that the 'Object' part of 'Object.Lock' was the object so I tried 'Button1.Lock' and similar.

Put it down to the age....

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest