Re: Issue with field margins when building a custom control based on a scrolling list field.
Posted: Wed Aug 02, 2023 5:46 pm
I haven't been following this closely but would the selectedLoc function be useful?
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
Simon,Simon Knight wrote: Wed Aug 02, 2023 5:08 pm
I have just noticed this happens if border and margins are both set to zero (text is 11) :
What logic is being employed and why?
Also just found this command :SCode: Select all
function getTopOfFirstLine return item 2 of the formattedRect of Line 1 of field "MyNewList" end getTopOfFirstLine
Code: Select all
function getTopOfFirstLine
return item 2 of the formattedRect of Line 1 of field "MyNewList"
end getTopOfFirstLineCode: Select all
on mouseDoubleDown pButtonNumber
// Enter edit mode
// Get the line no of the clicked row
put the effective textHeight of me into tCellHt
put the borderWidth of me into tBorderWidth //only applies to the outer boarder not the thin lines
put the leftMargin of me into tLeftMargin -- changed to leftMargin
put item 2 of the formattedRect of line 1 of me into tTopOfLines
put item 2 of (the mouseloc) into tMouseYcoOrd
// catch if doubleClick is above first line, otherwise it would create a LineEditor for line 0
if tMouseYcoOrd < tTopOfLines then
exit mouseDoubleDown
end if
put tMouseYcoOrd-(tTopOfLines - the vScroll of me) into tMouseYPosnInField
// Calculate the line number
put (tMouseYPosnInField)/tCellHt into tLineNo
put the floor of tLineNo + 1 into tLineNo
put "Line number : " & tLineNo into field "Details"
put tTopOfLines + ((tLineNo - 1)*tCellHt) - the vScroll of me +1 into tLineTop
put the scrollbarWidth of me into tScrollBarWidth
if not the vScrollBar of me then
put 0 into tScrollbarWidth
else
subtract 1 from tScrollbarWidth
end if
// size and position the field used for editing
set the height of field "LineEditor" to tCellHt - 1
set the width of field "LineEditor" to (the width of me)-(2*tBorderWidth) - tScrollbarWidth
set the top of field "LineEditor" to tLineTop
Set the left of field "LineEditor" to (the left of me + tBorderWidth)
set the textsize of field "LineEditor" to the effective textsize of me
set the margins of field "LineEditor" to tLeftMargin,5,0,0 --left, top, right, bottom
put line tLineNo of me into tLineText
// Store line number and text in custom variables
set the uEditingLineNo of field "LineEditor" to tLineNo
put the short name of me into tMyName
set the uParentFieldName of field "LineEditor" to tMyName
// Populate the field and make visible
put tLineText into field "LineEditor"
set the visible of field "LineEditor" to true
focus on field "LineEditor"
end mouseDoubleDownFor me the borderWidth setting is in effect regardless of the status of "showBorder" in LC 9.6.9 confirming your observation.Simon Knight wrote: Wed Aug 02, 2023 4:44 pm I have just seen this in the dictionaryI don't think it is correct at least on version 10 .If the object's showBorder property is false, the borderWidth property has no effect.
Just wondering if I should post a documentation bug report.
Simon
You should have told me that about 10 years ago...