Non-existent lines

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5323
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Non-existent lines

Post by dunbarx » Sun Dec 31, 2017 5:50 am

Make a new field, lock it ,load the first three lines, say, with text and then in a handler somewhere:

Code: Select all

on mouseUp
answer word 2 of the clickLine 
end mouseUp
If you click where, say, line 6 should be, you will not get a "6", rather you will get empty. This is because there is no sixth line, even though one has clicked where that line by all rights ought to be. And would indeed be if text extended down that far.

Now there are ways to derive that "6", of course, using other properties such as the clickV, the top of the field and the textHeight of the field. Whatever.

I understand the nature of a LC field that is empty below its existing text. Those "lines" do not yet exist.

In other words, would an "effective" clickLine be of interest to anyone? Is it worth suggesting?

Craig Newman

bogs
Posts: 1755
Joined: Sat Feb 25, 2017 10:45 pm

Re: Non-existent lines

Post by bogs » Sun Dec 31, 2017 6:01 am

Um, I must be somewhat dense at the moment, but I'm not sure I follow where the benefit would be to this.

You have 3 lines of text.
You know there is no text below that.
You want to have something that doesn't exist return something other than empty?

Oh dear, I've gone cross eyed again Image
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5938
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Non-existent lines

Post by FourthWorld » Sun Dec 31, 2017 6:51 am

dunbarx wrote:
Sun Dec 31, 2017 5:50 am
In other words, would an "effective" clickLine be of interest to anyone? Is it worth suggesting?
`The question they'll ask is: what is the use case that requires it?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2433
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Non-existent lines

Post by richmond62 » Sun Dec 31, 2017 10:05 am

Cannot think of any reason for that.
lines.png
LINES.livecode.zip
(1.1 KiB) Downloaded 13 times

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 49
Joined: Fri Nov 25, 2011 6:42 pm
Location: Kansas City
Contact:

Re: Non-existent lines

Post by tomBTG » Sun Dec 31, 2017 5:24 pm

I can't imagine needing to know the position of non-existent lines. But I can image an easy solution for you: just add to the field's text the number of RETURNS needed to fill up the field. Then your code will report those line numbers.

HTH,
Tom B.

Klaus
Posts: 9978
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Non-existent lines

Post by Klaus » Sun Dec 31, 2017 5:37 pm

Hi Craig,

something like this will give you the "virtual" clickline, script of an EMPTY "default" and locked scrolling field:

Code: Select all

on mouseUp
   put the mouseV into tY
   put the effective textheight of me into tTH
   put tY - the top of me + the topmargin of me into tCurrentLine
   answer "You clicked the virtual line:" && round(tCurrentLine/tTH)
end mouseUp
May need some adjustment, but works as exspected so far :-)


Best

Klaus

Klaus
Posts: 9978
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Non-existent lines

Post by Klaus » Sun Dec 31, 2017 5:54 pm

P.S.:
And I really don't care WHY you want to know this, since this is no "philosophy today" forum! :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4384
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Non-existent lines

Post by jacque » Sun Dec 31, 2017 6:08 pm

I'm curious though, since in 30 years I've never needed to know that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5323
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Non-existent lines

Post by dunbarx » Sun Dec 31, 2017 6:28 pm

Hmmm.

@ Klaus. Certainly. I mentioned properties that would do what your offering did. Thank you. We think alike.

@ You other mooks... (Not you, Jacque)

Say you wanted to insert a line of text into a "virtual" (thanks again, Klaus) line a bit below the "real" lines of a field. One can always:

Code: Select all

put "foo" into line 12 of fld "fieldWithOnlyThreeLinesInIt"
and LC will happily "create" the 12th line and load it with our beloved "foo".

So LC knows where line 12 needs to be. One might say it knows where line 12 actually is, even though it does not yet exist. But the point I was trying to make is that a mouseClick on that, er, line, just don't have no zest appeal.

And therefore might it be useful to be able to access what LC already knows:

Code: Select all

on mouseUp
get  word 2 of the effective clickLine
put "foo" into line it of fld "fieldWithOnlyThreeLinesInIt"
end mouseUpp
Click, in my dreams, on line 12 of that field.

And if that is useful, we no longer need the ordinary clickLine function; simply enhance it to this one.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2433
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Non-existent lines

Post by richmond62 » Sun Dec 31, 2017 6:30 pm

"mook" ?

coining new words for the new year?

Love and Kisses, Richmond. 8)

bogs
Posts: 1755
Joined: Sat Feb 25, 2017 10:45 pm

Re: Non-existent lines

Post by bogs » Sun Dec 31, 2017 9:09 pm

Proud card carrying 'mook' for 50 years, and counting :wink: Happy New Years (eve/day) on clickLine virtualInfinity!
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4384
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Non-existent lines

Post by jacque » Sun Dec 31, 2017 9:30 pm

dunbarx wrote:
Sun Dec 31, 2017 6:28 pm
and LC will happily "create" the 12th line and load it with our beloved "foo".

So LC knows where line 12 needs to be.
I'm not sure about that. I'd guess that LC is just adding enough carriage returns to create 12 lines and then inserting content. We could do that too in script.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1682
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Non-existent lines

Post by [-hh] » Sun Dec 31, 2017 11:24 pm

Craig,
what makes you think you know "the" line number for that click?
A fixed lineHeight, a non-wrapped field, a black foreColor on a white background, a visible vscrollbar?

@ALL: Have a nice end of 2017!

H.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5323
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Non-existent lines

Post by dunbarx » Mon Jan 01, 2018 12:25 am

Hermann.

I usually work with fixed lineHeights and textSizes, but you make a point.

I assume an unwrapped field, but you make a point.

Scrollbars can be dealt with, using the "scroll" function, just as we all have mentioned with script gadgetry that does the work I am talking about. But you make a point

Black foreColors? White backgrounds? Oh yes, it is already new years where you are. Have another schnapps on me. :wink:
I'd guess that LC is just adding enough carriage returns to create 12
Jacque.I would think so as well. Much more straightForward than taking account of all those other properties and doing all that figuring.

So no traction. OK.

Craig

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1682
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Non-existent lines

Post by [-hh] » Mon Jan 01, 2018 1:08 am

If that is all fixed then you could translate every clickloc to a non-existent pixel of a non-existent char x of the non-existent line y of your (non-existent?) field, and back. ;-))

Happy new year Craig. Hopefully we have once again a year with extraordinary ideas by you (from 2017 only the current one is funny, TMHO).
shiftLock happens

Post Reply

Return to “Talking LiveCode”