I'm on a Mac running Big Sur and Livecode Indy 9.6.1 and the problem described occurs in the IDE.
I have a project that is a stack with two cards "Main" and "Settings". Card "Main" has what is a complex list based custom control which came from Scott Rossi's web site. This control uses a behaviour button which is stored in a separate Stack named Behaviours. One of the handlers in the behaviour button updates the custom control and this update handler gets called from the open card handler via a default settings handler on the card. The settings card has no handlers that are called when it is closed.
The custom control is named "ListOfShoots" so the calling chain is:
On Opencard calls "EmptyListOfShoots" which is a handler on the card.
On EmptyListShoots sends "updateMyAppearance" to field "ListOfShoots"
Field "listOfShoots" runs the handler which is in its behaviour button.
This triggers multiple calls of handlers within the behaviour button which are called to make settings on every row used in the list. Typically there are between one and nine rows but the default is three.
This all sounds complex but it is a quite common structure and no different to how a datagrid is implemented. Also this structure has worked for months but recently a problem became apparent.
When switching from the settings card back to the main card the display of the main card has started to freeze with the main card only partially drawn or visible on my screen. I believe I captured a screen shot of the situation but the resulting image shows the card fully drawn.
There is a simple solution as the issue disappears if I add a line "wait 1 milliseconds with messages" in the opencard handler. However I am concerned that this fix is hiding a more complex problem.
Also I have noticed some other issues when in the IDE : some code changes I make to my code do not always stick also from time to time the line numbers stop scrolling with the code.
So is my code breaking the IDE or is the IDE breaking my code and why does a 1 millisecond delay seem to solve the card redraw issue?
Any ideas ?
I'm sure someone will ask for the code so here goes:
Code: Select all
on opencard
   wait 1 milliseconds with messages
   EmptyListOfShoots
end opencardCode: Select all
On EmptyListOfShoots
   put "-,-,Please select a Source Folder" & CR & "-,-,of images to rename and copy" & CR & "-,-, to folder chosen above. " into tListOfShootDates
   replace comma with tab in tListOfShootDates
   put tListOfShootDates into field "ListofShoots"
   put 3 into tRowCount
   
   # Resize the list
   put the textheight of field "ListOfShoots" into tLineHt
   put the uTablePadding of field "ListOfShoots" into tpadding
   put (2 * tPadding)+ tLineHt into tRowHt
   put tRowCount * tRowHt into tHeightOfTable
   put the top of field "ListOfShoots" into tTop
   
   set the top of field "ListOfShoots" to tTop 
   set the vscrollbar of field "ListOfShoots" to False
   send "updateMyAppearance" to field "ListOfShoots"
end EmptyListOfShootsCode: Select all
command updateMyAppearance
   lock screen
   repeat with N = 1 to number of lines of me
      if N = (the hilitedLine of me) then
         set the hiliteColor of me to myHiliteColor()
         set backColor of line N of me to myHiliteColor()
         set textColor of line N of me to myHilitedTextColor()
         next repeat
      end if
      set textColor of line N of me to myTextColor()
      if N mod 2 <> 0 then
         set backColor of line N of me to myOddRowColor()
      else set backColor of line N of me to myEvenRowColor()
   end repeat
   set padding of line 1 to -1 of me to myPadding()
   set borderColor of me to mySeparatorColor()
   set vGrid of me to myShowSeparators()
   set textHeight of me to myLineHeight()
   unlock screen
end updateMyAppearanceHere is all of the code in the behaviour button, but this has worked for months in this project and in others.
Code: Select all
before mouseEnter
   put false into allowTracking
end mouseEnter
before mouseDown
   updateMyAppearance
   put true into allowTracking
end mouseDown
before mouseMove X,Y
   if not allowTracking then exit mouseMove
   updateMyAppearance
end mouseMove
before mouseUp
   put false into allowTracking
end mouseUp
before mouseRelease
   put false into allowTracking
end mouseRelease
command updateMyAppearance
   lock screen
   repeat with N = 1 to number of lines of me
      if N = (the hilitedLine of me) then
         set the hiliteColor of me to myHiliteColor()
         set backColor of line N of me to myHiliteColor()
         set textColor of line N of me to myHilitedTextColor()
         next repeat
      end if
      set textColor of line N of me to myTextColor()
      if N mod 2 <> 0 then
         set backColor of line N of me to myOddRowColor()
      else set backColor of line N of me to myEvenRowColor()
   end repeat
   set padding of line 1 to -1 of me to myPadding()
   set borderColor of me to mySeparatorColor()
   set vGrid of me to myShowSeparators()
   set textHeight of me to myLineHeight()
   unlock screen
end updateMyAppearance
# HILITED LINE
setProp hilitedTableRow pValue
   lock screen
   set hilitedLine of me to pValue
   updateMyAppearance
   unlock screen
end hilitedTableRow
getProp hilitedTableRow
   return hilitedLine of me
end hilitedTableRow
# TEXT COLOR
setProp tableTextColor pValue
   set the uTableTextColor of me to pValue
   updateMyAppearance
end tableTextColor
getProp tableTextColor
   return myTextColor()
end tableTextColor
function myTextColor
   return the uTableTextColor of me
end myTextColor
# ODD ROW COLOR
setProp tableOddRowColor pValue
   set the uTableOddRowColor of me to pValue
   updateMyAppearance
end tableOddRowColor
getProp tableOddRowColor
   return myOddRowColor()
end tableOddRowColor
function myOddRowColor
   return the uTableOddRowColor of me
end myOddRowColor
# EVEN ROW COLOR
setProp tableEvenRowColor pValue
   set the uTableEvenRowColor of me to pValue
   updateMyAppearance
end tableEvenRowColor
getProp tableEvenRowColor
   return myEvenRowColor()
end tableEvenRowColor
function myEvenRowColor
   return the uTableEvenRowColor of me
end myEvenRowColor
# HILITED LINE COLOR
setProp tableHiliteColor pValue
   set the uTableHiliteColor of me to pValue
   updateMyAppearance
end tableHiliteColor
getProp tableHiliteColor
   return myHiliteColor()
end tableHiliteColor
function myHiliteColor
   return the uTableHiliteColor of me
end myHiliteColor
# HILITED TEXT COLOR
setProp tableHilitedTextColor pValue
   set the uTableHilitedTextColor of me to pValue
   updateMyAppearance
end tableHilitedTextColor
getProp tableHilitedTextColor
   return myHilitedTextColor()
end tableHilitedTextColor
function myHilitedTextColor
   return the uTableHilitedTextColor of me
end myHilitedTextColor
# SEPARATOR COLOR
setProp tableSeparatorColor pValue
   set the uTableSeparatorColor of me to pValue
   updateMyAppearance
end tableSeparatorColor
getProp tableSeparatorColor
   return mySeparatorColor()
end tableSeparatorColor
function mySeparatorColor
   return the uTableSeparatorColor of me
end mySeparatorColor
# SEPARATOR VISIBILITY
setProp tableShowSeparators pValue
   set the uTableShowSeparators of me to pValue
   updateMyAppearance
end tableShowSeparators
getProp tableShowSeparators
   return myShowSeparators()
end tableShowSeparators
function myShowSeparators
   return the uTableShowSeparators of me
end myShowSeparators
# TEXT SHIFT VALUE
setProp tableTextShift pValue
   set the uTableTextShift of me to pValue
   updateMyAppearance
end tableTextShift
getProp tableTextShift
   return myTextShift()
end tableTextShift
function myTextShift
   return the uTableTextShift of me
end myTextShift
# PADDING
setProp tablePadding pValue
   set the uTablePadding of me to pValue
   updateMyAppearance
end tablePadding
getProp tablePadding
   return myPadding()
end tablePadding
function myPadding
   return the uTablePadding of me
end myPadding
# LINE HEIGHT
setProp tableLineHeight pValue
   set the uTableLineHeight of me to pValue
   updateMyAppearance
end tableLineHeight
getProp tableLineHeight
   return myLineHeight()
end tableLineHeight
function myLineHeight
   return the uTableLineHeight of me
end myLineHeight