Issue with field margins when building a custom control based on a scrolling list field.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Issue with field margins when building a custom control based on a scrolling list field.
I haven't been following this closely but would the selectedLoc function be useful?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 4028
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Issue with field margins when building a custom control based on a scrolling list field.
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
at margins 0 text is alway cut off by 1 pixel.
Code: Select all
function getTopOfFirstLine
return item 2 of the formattedRect of Line 1 of field "MyNewList"
end getTopOfFirstLine
It does seem to do the trick, I just never knew/found this although I did play around with formattedRect quite a bit.
This is the current version the mouseDoubleUp handler for field "myNewList". No need for function getTopOfLine.
This handler seems to take care of it all. (note I added a conditional to catch doubleClick above first line, it would otherwise place an editorField into line 0)
Code: 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 mouseDoubleDown
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 4028
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Issue with field margins when building a custom control based on a scrolling list field.
For 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 pmI 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
It is definitely a documentation bug. The behavior may have changed with the rewrite in LC 7 series.
I would report it.
Kind regards
Bernd
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Issue with field margins when building a custom control based on a scrolling list field.
You should have told me that about 10 years ago...
I wonder when the command was introduced ?
I found it by going down the list of field properties / commands looking for other issues like the Borderwidth error.
There are several where the syntax example either does not work, throws an error or does not appear to apply to a field object.
So I was surprised that calling the formatted rectangle of line n did work as I expected it to be another documentation error.
Simon
best wishes
Skids
Skids
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Issue with field margins when building a custom control based on a scrolling list field.
Thank you for all your inputs. The final version of the control is on the attached stack.
best wishes
Simon
best wishes
Simon
best wishes
Skids
Skids