PDF widget print quality

2024-02-20 Thread David Epstein via use-livecode
I want to use the PDF widget to print a PDF with additional markings added in 
LiveCode.  Showing a simple PDF tax form in Widget 1 at 100% scale, I tried 
this script:

on p1

get the pageRect of widget 1

open printing with dialog

print card from (item 1 to 2 of it) to (item 3 to 4 of it) into it

close printing

end p1


This prints a full page at the proper size, but not with acceptable print 
quality; everything is slightly blurred and pixellated.  How can I get a good 
quality printout?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: LockLoc and grab

2024-01-23 Thread David Epstein via use-livecode
Let me try to clarify the problem I stated.

I am not trying to remove the button, I am trying to use the “grab” command to 
let a user move the button around the window by dragging it.

If I use a script to “set the loc” of a button to somewhere outside that 
group’s rectangle
- the group will resize if its lockLoc property is false (thus keeping 
the relocated button visible); 
- but the button will disappear if the group’s lockLoc property is true.

But when I use the “grab” command to relocate the button outside the group’s 
current rectangle the group does not resize even if its lockLoc property is 
false.



> A group with lockLoc set to false does not resize itself when an object in it 
> is moved by a ?grab? command.  Is this a bug?  Is there a simple workaround?
> 
> Recipe using 10.0.0 dp6 on an intel Mac:  
> 
> Create a button with this script:  
> on mouseDown; grab me; end mouseDown.  
> Group the button.  Confirm that the group?s lockLoc property is false.  Then 
> with the browse tool, drag the button past the edge of the group.  The button 
> disappears.
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


LockLoc and grab

2024-01-22 Thread David Epstein via use-livecode
A group with lockLoc set to false does not resize itself when an object in it 
is moved by a “grab” command.  Is this a bug?  Is there a simple workaround?

Recipe using 10.0.0 dp6 on an intel Mac:  

Create a button with this script:  
on mouseDown; grab me; end mouseDown.  
Group the button.  Confirm that the group’s lockLoc property is false.  Then 
with the browse tool, drag the button past the edge of the group.  The button 
disappears.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Comparative speed in switching among groups

2023-11-28 Thread David Epstein via use-livecode
Many thanks to Richard, for his interesting results and for the reminder that 
speed testing is pretty easy.  I ran a similar test on a slightly different 
task--flipping among 50 different groups, or 50 different cards--and got 
similar results.  Adding a “lock messages” sped up the card option by a factor 
of 4, but the group option was much, much faster even then.
I’m trying to make it possible to scan quickly through a long document.
The remarks of Richard and Alex raise these questions for me:
1.  Is LC recalculating the line wraps of all fields every time we go to a 
card?  Is it not doing that when a hidden field on a card is shown (or is the 
field somehow “ready to go” even when the field is hidden)?
2. On the question of resizing:  One possibility is to adjust groups when 
(i.e., just before) they are shown.  But would it be speedier to do this in 
advance, when nothing else is happening?  The User Guide says “timer based 
messaging [is] ideal where you want your user interface to remain responsive.”  
I’m not sure exactly how to do this, but it seems like on a resize event one 
could make a list of the hidden groups that need to be adjusted, and call them 
one at a time with something like 
send “upDateGroupLayout oneGroupID” to me in 10 milliseconds.  Is that right?

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Comparative speed in switching among groups

2023-11-25 Thread David Epstein via use-livecode
Does anyone have practical experience or an understanding of the engine that 
would cast light on the relative speed of some alternative ways of doing 
things?  I want to switch among a number of different groups, each of which may 
contain its own fields, graphics, buttons, and images.  Possible approaches:

- Have many different cards, each with a group peculiar to it, and GO TO each 
card as desired, or

- Have one card, with many different groups, and SHOW/HIDE the groups as 
desired, or

- Have many different cards, each with a group peculiar to it, and COPY a group 
from an unseen card to a single card that is always seen (and DELETE the 
unwanted group on that single card).

There are other considerations that affect a choice among these methods, but my 
concern here is the speed with which I can switch from displaying one group to 
displaying another.   I am wondering whether at some level these methods all 
amount to the same thing from the engine’s point of view (since everything is 
in RAM in any case).

Many thanks.

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-04 Thread David Epstein via use-livecode
I do not know how my problems accessing the rawClipboardData were overcome, 
but I succeeded in reading the array values there.  So I was able to address my 
original question of how to reconstruct in LiveCode a combination of text and 
image copied from another program.  Conclusion thus far:  no success.  If 
anyone is interested in this and might have some further suggestions, read on.

When I use the control key to invoke from the contextual menu “copy image” on a 
web page, the fullClipboardData[“image”] gets a string of humanly 
unintelligible characters that, when used as the text of a LiveCode image 
object, shows the copied image.   I did this for the picture of Robert Cailliau 
on webpage https://livecode.com/core-benefits-of-livecode/.  Call this String A.

To see how this information might be stored when I have copied both text and 
image, I selected from the word before to the word after that same picture, 
chose “Copy,” and then inspected the rawClipboardData["com.apple.flat-rtfd”], 
which seemed the most promising candidate of the various clipboardData array 
values.  Call this String B.

Something that looks kind of like String A appears in String B, but it is not 
the same.

At char 4097 of String B I see the first few characters of the beginning of 
String A, and think this might define the PNG data to follow.  But what follows 
is not the same as String A.

Here’s the start of string A:

âPNG
IHDR,,y}éusRGBÆŒÈDeXIfMM*ái††,†,ÿ`ÇÁ@IDATxÏΩ

And here’s char 4097ff of String B;

âPNG
IHDR,,y}éu IDATxúÏΩ{¨mYv÷˜sƵˆ„ÏÛ∏˜ú{Îvuuwuπ‹.€Ìˆ«!,d«2$qä¯a«9éCj,d°!dÅ"EâàB 

So my hope that String A could somehow be extracted from String B and used to 
“paste” the included image was disappointed. 

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together

2023-09-02 Thread David Epstein via use-livecode
Paul, getting the keys of the rawClipboardData worked for me too.  What didn’t 
work was trying to read the values.  See this part of my script, I hope shown 
this time without the asterisks gMail added before:

   lock clipboard
  …
   put the keys of the rawClipboardData into myK3  ## THIS WORKS
   …
   repeat for each line k in myK3
  try
 put the rawClipboardData[k] into temp[n]  ## DOESN’T WORK
  catch myError
 put myError into e4[n] ## ERROR IS TRIGGERED
  end try
  add 1 to n
   end repeat
   unlock clipboard



> From: Paul Dupuis 
> To: use-livecode@lists.runrev.com
> Subject: Re: Pasting text and images together?
> Message-ID: <3814cd2a-0f20-2bbb-8783-42fc57e68...@researchware.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
> 
> Since my method didn't work, I'd try Marks, namely to put the keys of 
> the clipboard array into a variable to look at
> 
> on mouseUp
> ? lock clipboard
> ? put the keys of the clipboarddata into tKeys1
> ? put the keys of the fullclipboarddata into tKeys2
> ? put the keys of the rawclipboarddata into tkeys3
> ? breakpoint
> ? unlock clipboard
> end mouseUp
> 
> I tested this in LC 10dp6 and it works. Once you see what keys are 
> present with your mixed text and images copied to the clipboard, you can 
> choose which clipboard array and keys to work with to get the data.
> 
> -- Paul
> 
> 
>> On 9/2/2023 10:36 AM, David Epstein via use-livecode wrote:
>> Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
>> test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
>> execution after the breakpoint, I get errors at each "try" in the script.
>> So it does not seem that I can write the fullClipboardData
>> or rawClipboardData to an array variable; and it does not seem that I can
>> access any element of the rawClipboardData array.  Further advice is
>> welcome.
>> 
>> Best wishes,
>> David Epstein
>> 
>> *on* a2
>> 
>> *lock* clipboard
>> 
>> *put* the keys of the clipboardData into myK1
>> 
>> *put* the keys of the fullClipboardData into myK2
>> 
>> *put* the keys of the rawClipboardData into myK3
>> 
>> *breakpoint*
>> 
>> *try*
>> 
>> *put* the fullClipboardData into ta2
>> 
>> *catch* myError
>> 
>> *put* myError into e2
>> 
>> *end* *try*
>> 
>> *try*
>> 
>> *put* the rawClipboardData into ta3
>> 
>> *catch* myError
>> 
>> *put* myError into e3
>> 
>> *end* *try*
>> 
>> *put* 1 into n
>> 
>> *repeat* for each line k in myK3
>> 
>> *try*
>> 
>> *put* the rawClipboardData[k] into temp[n]
>> 
>> *catch* myError
>> 
>> *put* myError into e4[n]
>> 
>> *end* *try*
>> 
>> *add* 1 to n
>> 
>> *end* *repeat*
>> 
>> *unlock* clipboard
>> 
>> *end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-02 Thread David Epstein via use-livecode
Many thanks to Paul Dupuis and Mark Waddingham.  The script below tries to
test their suggestions.  Using 10.0.0 dp5 on an Intel Mac, and watching
execution after the breakpoint, I get errors at each "try" in the script.
So it does not seem that I can write the fullClipboardData
or rawClipboardData to an array variable; and it does not seem that I can
access any element of the rawClipboardData array.  Further advice is
welcome.

Best wishes,
David Epstein

*on* a2

*lock* clipboard

*put* the keys of the clipboardData into myK1

*put* the keys of the fullClipboardData into myK2

*put* the keys of the rawClipboardData into myK3

*breakpoint*

*try*

*put* the fullClipboardData into ta2

*catch* myError

*put* myError into e2

*end* *try*

*try*

*put* the rawClipboardData into ta3

*catch* myError

*put* myError into e3

*end* *try*

*put* 1 into n

*repeat* for each line k in myK3

*try*

*put* the rawClipboardData[k] into temp[n]

*catch* myError

*put* myError into e4[n]

*end* *try*

*add* 1 to n

*end* *repeat*

*unlock* clipboard

*end* a2
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Pasting text and images together?

2023-09-01 Thread David Epstein via use-livecode
To clarify my original question:

I'm not expecting the built-in paste command to handle this task; I'm
wondering if I can script my own paste command to handle it.

Richmond, I can write a script to "paste" an image by itself (by creating
an image and setting its text to clipboardData["image"]).

But is there some way I can access both the text and the image that are on
the clipboard after I have copied a combination of those from, e.g., a web
browser?  (Pasting to Apple Notes confirms that the clipboard contains both
text and image.)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Pasting text and images together?

2023-08-30 Thread David Epstein via use-livecode
From a web browser, or from programs like Word or (Apple) Notes, it is possible 
to copy to the clipboard a single selection that includes both text and images.
Is there any way to paste all of this information to LiveCode—for example, 
placing the text in fields and the imageData in image objects, or showing 
everything in one field by setting the imageSource of some characters in that 
field?
After having copied such a collection of text and image information, the keys 
to the fullClipboardData seem only to include text and styled text options, 
with no indication of the images that are included on the clipboard.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Detecting when resizeStack is completed

2023-08-18 Thread David Epstein via use-livecode
How can I redraw objects after the user has resized the stack, but not 
continuously during the resize?  Releasing the mouse at the end of a resize 
does not appear to send a mouseUp message.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Remote debugger error message

2023-07-02 Thread David Epstein via use-livecode
panagiotis m asked:
@david
How do you trigger this error? Could you provide a recipe?

With the stacks that trigger the error it is hard to troubleshoot them without 
triggering the error.  So I’m starting with an entirely new stack, and will 
report if I encounter the problem.

I suspect the problem has something to do with a message that calls a handler 
in a stack-in-use.

Best wishes,
David

> 
> 
> On Thu, Jun 29, 2023 at 8:40?PM David Epstein via use-livecode
> mailto:use-livecode@lists.runrev.com>> wrote:
>> 
>> I?ve just started using LiveCode 9.6.9 and 10.0.0 DP 5 on two Intel
> Macs, and can do very little without getting this error message:
>> 
>> ?There was an error executing a script in stack
> com.livecode.library.remotedebugger.  No more information is available
> because the stack is password protected.?
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Remote debugger error message

2023-06-29 Thread David Epstein via use-livecode
I’ve just started using LiveCode 9.6.9 and 10.0.0 DP 5 on two Intel Macs, and 
can do very little without getting this error message:

“There was an error executing a script in stack 
com.livecode.library.remotedebugger.  No more information is available because 
the stack is password protected.”

I can click OK, but the error message soon returns.

Any suggestions?

Best wishes,
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


PDF widget and XPDFviewer

2023-06-17 Thread David Epstein via use-livecode
What is the relation between the widget “PDF” and the external “XPDFViewer” 
(both in Pro Features)?  The latter offers more direct access to a few 
properties (e.g., totalCharacterCount), while the widget syntax is a little 
simpler.  It does not appear that a PDF widget is a PDF Viewer, at least the 
widget’s name is not recognized as the name of a viewer when I try to call a 
function like XPDFViewer_Get(viewerName,property).

So do I need either to create a widget or create a viewer?  And are there 
non-obvious reasons to do one or the other?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Maximum field size

2023-01-20 Thread David Epstein via use-livecode
My testing attempts, like Bernd’s, show that the important “limits” are not 
just what LC can display in a field but what it can display without making 
things too slow.  I am also wondering if the new polyGrid has different 
characteristics, either its absolute limits or its performance when heavily 
populated.

Richard Gaskin asks “Why?”

I have developed a set of routines to analyze tabular data.  For KB or MB-sized 
files, it is convenient to display them in a field.  It would be simplest if I 
could also load GB-sized files and use my routines unchanged, but I accept that 
this is impractical.  But in order to design workarounds I’d like to get as 
much clarity as possible on what limits I am working around.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Maximum field size

2023-01-19 Thread David Epstein via use-livecode
Thanks to Bernd for this:

> Maximum length of a line in a field:
> 65,536 characters storage
> No more than 32,786 pixels wide for display

This seems to mean we can have a 65k long line only if each character’s width 
is around half a pixel.
And that if the character width is 10 pixels the maximum line is 6,553 
characters.
Or does “for display” mean something else?

And, if we respect the line length limit, is the number of lines in a field 
limited only by however much of minimum(RAM, LC’s 4GB “total addressable 
space”) is not being used by something else?
So for example would trying to load a 2.1 GB variable in a field surpass the 
4GB limit, because the variable and the field would each need 2.1 GB?

Best wishes,
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Maximum field size

2023-01-18 Thread David Epstein via use-livecode
How many rows or columns or characters can reasonably be displayed in a 
LiveCode field?  A 1.39 GB text file seems pretty clearly to surpass the limit, 
but how much do I need to subdivide it?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Livecode performance problem

2022-08-20 Thread David Epstein via use-livecode
I didn’t text the speed, but why not

put fld A into x[1]
put fld B into x[2]
put fld C into x[3]
put fld D into x[4]
combine x by column
return x

> 
> I have a set of fields, call them A, B, C, and D. Each has the same 
> number of lines. Each field has different text (per line)
> 
> I need to combine the data - frequently - into a form that look like:
> 
>  C>


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Chart widget question

2022-08-03 Thread David Epstein via use-livecode
Using LC 10 dp2, I am trying to script the creation of a chart widget.  

My command “create widget myName as chart in group myMain” creates only a small 
gray box.  

The LC command “New Widget/Chart” creates a line chart, ready to be modified.  
What is the LC command doing that I am not?

Or:  how do I find the script that LC runs when the “New Widget/Chart” command 
is chosen?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Is there a way to create a generic setprop handler?

2022-08-03 Thread David Epstein via use-livecode
Control “A” has many custom properties that are set by a variety of other 
controls.  If Control “A” has a "setProp property1” handler, it can react when 
property1 gets set.  But is there a way to give Control “A” a general handler 
that will be triggered whenever any of its custom properties is set?

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Using LiveCode with Mac Photos App

2022-04-18 Thread David Epstein via use-livecode

I want to allow selection of some images from my Mac Photos library and show 
them as “referenced” images in a LiveCode stack.  Is there an efficient way to 
do this?
What would be great is to open Photos, drag images from there to my LiveCode 
stack, and record in LiveCode the file location of the original image.  But 
this seems not to work from within Photos, only with images that have been 
exported (e.g., I can drag exported images from my desktop to a LiveCode stack 
and get the dragData[“files”]).
Is there any way from within Photos to gain access to the file locations for 
convenient use by LiveCode?
David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Shaping an image to fit in a polygon

2021-10-18 Thread David Epstein via use-livecode
Jacqueline Gay’s suggestion is excellent, and by exactly aligning the rect of 
the polygon with the rect of the image being “trimmed”, I can avoid having the 
image centered or repeated.  See script below.  

I am still wondering what goes wrong with my alphaChannel approach to showing 
irregularly shaped images.  Is there some imprecision in the “within” function? 
 This would be important to know for other uses of it.

David Epstein

on imageToGrc gID
  # fills graphic id gID with image it is positioned on; works for polygon, 
oval, regular, or rectangle
  set the linesize of grc id gID to 0
  set the filled of grc id gID to false
  wait 1 ticks # seems needed so that linesize of 0 is respected
  hide grc id gID
  import snapshot from rectangle globalRect(the rect of control id gID)
  put the short id of image (the number of images) into imID
  set the rect of image id imID to the rect of grc id gID
  set the filled of grc id gID to true
  set the backgroundPattern of grc id gID to imID
  show grc id gID
  set the loc of grc id gID to the bottomRight of grc id gID ## to make it 
visible
  hide image id imID  ## note:  don’t delete, or polygon loses the image
  choose browse tool
end imageToGrc

function globalRect theRect
  return globalLoc(item 1 to 2 of theRect),globalLoc(item 3 to 4 of theRect)
end globalRect
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Shaping an image to fit in a polygon

2021-10-16 Thread David Epstein via use-livecode
I am trying to create an image that will appear to have the shape of some 
arbitrary polygon.  The idea is to set the image's alphaData so that pixels 
within the polygon are opaque, and those outside the polygon are transparent.  
The scripts below create a rectangular image of whatever is under the polygon's 
enclosing rectangle, and then adjust the alphaData of that new image.  But 
while the new image gets trimmed a bit, the result does not match the shape of 
the designated polygon.  Any thoughts?

David Epstein

on action gID ## gID is the short id of the polygon
  import snapshot from rectangle globalRect(the rect of control id gID) 
  put the short id of image (the number of images) into imID
  set the width of image id imID to the width of grc id gID
  set the height of image id imID to the height of grc id gID
  set the loc of image id imID to the loc of grc id gID
  set the polyCrop of image id imID to gID
end action

function globalRect theRect
  return globalLoc(item 1 to 2 of theRect),globalLoc(item 3 to 4 of theRect)
end globalRect

setProp polyCrop polyID
  -- crop target image's alphadata to show only points within grc id polyID
  put the filled of grc id polyID into fillState
  set the filled of grc id polyID to true
  put the rect of the target into r
  put numToChar(255) into P ## opaque
  put numToChar(0) into T ## transparent
  repeat with y = 1+item 2 of r to item 4 of r ## SEE NOTE*
repeat with x = 1+item 1 of r to item 3 of r
  put x,y into myPoint
  if within(grc id polyID,myPoint) then put P after hold else put T after 
hold
end repeat
  end repeat
  set the filled of grc id polyID to fillState
  set the alphaData of the target to hold
end polyCrop

* NOTE:  the "1+" is these statements is my effort to step through the exact 
number of pixels in the width and height of the image.  The number of values in 
the series (item 1 of the rect of the image) to (item 3 of the rect of the 
image), inclusive, is 1+ the width of the image.  (But I am not really sure 
whether to add 1 to the first value or subtract 1 from the last value).
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Implementing UNDO

2021-05-21 Thread David Epstein via use-livecode
LC’s built in undo does not appear to undo anything done by something I have 
scripted.
My approach is to use a global array variable “u” to store information needed 
to undo the most recent action.  On each action, an “undoInit” puts empty into 
u, after (if necessary) cleaning up anything u’s values indicate is left over 
from the prior action (e.g., actually deleting an object that had been only 
“pseudo-deleted” (hidden) so as to make the user’s choice of deletion 
undoable).  Then the appropriate new values are loaded into u.  The main 
elements I use are

# u["cardID"] = short id of the card where the undoable action was taken
# u["stackName"] = short name of the stack where the undoable action was taken
# u["changed"], list of objects being changed, each line has:  propName,objectID
# u[propName,objectID] holds prior value of that property of that object (one 
key/value for each line of u["changed"]
# u["removed"], list of objectID,cardID,stackName for objects being 
pseudo-removed
# u["added"], list of objectID,cardID,stackName for objects being added
# u["cardsRemoved"], list of cards being pseudo-removed, each line has:  
cardID,cardNumber
# u["cardsAdded"], list of cards being added, each line has:  cardID,cardNumber

The “Undo” command makes sure we’re on card id u[“cardID”] of stack 
u[“stackName”}, then checks for non-empty values of 
u[“changed”],u[“removed”],u[“added”],u{“cardsRemoved”], and u[“cardsAdded”], 
and uses values stored in u to restore the prior state of things, while 
reloading u with values reporting the state of things now being reversed.

For text, I load u[“changed”] with “htmlText”,, and load 
u[“htmlText”,] with the htmlText of that field before the latest 
editing.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Smooth scrolling

2021-02-01 Thread David Epstein via use-livecode
My impression is that a LiveCode field scrolls less smoothly than a comparable 
field in some other programs, such as MS Word and Scrivener.  If I paste about 
25,000 words into a word wrapped scrolling field, and then drag the scrolling 
thumb up and down there is much more jumpiness than I see when I do the same 
thing to the same text in those other programs.  (LC 9.6 on Mac OS 10.12.6).  
Do others see the same thing?  Does anyone know the underlying cause of this, 
or a remedy?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Updating a menubar button on Mac

2020-09-21 Thread David Epstein via use-livecode
I can use a “mouseEnter” handler to update a menu button’s contents just before 
the user displays that menu.  But if that menu button is part of the stack’s 
menubar group on a Mac, the Mac menu does not seem to receive the mouseEnter 
message and the menu is not updated.  Is there a workaround?  Thank you!

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Saving stacks before closing

2020-05-24 Thread David Epstein via use-livecode
I want to give the user a choice of whether to save changes before closing a 
stack.  To script this, I will handle the closeStackRequest message, and find a 
way to keep track of whether the stack in question has been changed since it 
was last saved.

What I am trying to figure out is under what circumstances LiveCode takes care 
of this without my scripting it.  In the LiveCode IDE, trying to close an 
unsaved stack seems automatically to ask me whether I want to save changes (but 
I have not found a handler in the backscripts that implements this).  This is 
true of stacks I have created with the IDE “new stack” tool and then try to 
close.  Is it also true of stacks I have created by script?  

And what happens in a standalone?  Does this feature still work there?

In short, do I need to script an option to save changed stacks before closing, 
or can I rely on LiveCode to take care of this?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: DataGrid question...

2020-03-30 Thread David Epstein via use-livecode
This is more or less Jacqueline Gay’s suggestion, but with a couple of 
wrinkles.  You do need to adjust for the horizontal scroll of the field (I’m 
not sure about borders or margin).  And if I am not mistaken sometimes “the 
tabStops” will not have an entry for each tab, if the column width stays 
constant.
My approach is to keep a global called gColGuide, which gets reloaded when 
column widths change.  It has one line per column, with leftEdge,0,rightEdge,0 
in each line.
The function used to load gColGuide is shown below.

put word 1 of the clickLoc into x
put word 2 of the clickLine into L — line number
put the hScroll of fld “table” into hs

put colGuide() into gColGuide

function mCol x,hs — returns column number for horizontal pixel x, consulting 
gColGuide.  hs is the field’s hScroll.
  global gColGuide
  add hs to x
  put 1 into c
  repeat for each line k in gColGuide
if x > item 1 of k and x < item 3 of k then return c
add 1 to c
  end repeat
  return empty
end mCol-- Any need to adjust for borders and margins?

function colGuide — used to load gColGuide with one line per column; each line 
has left,0,right,0
  set itemDelimiter to tab
  put the number of items in fld "headers" of into cz
  set itemDelimiter to comma
  get the tabStops of fld “table”
  put "0," before it
  put the left of fld “table” into fL
  repeat with n = 1 to min(cz,(-1 + the number of items in it)) -- so that 
colGuide will only cover the used columns.
put fL+8 + item n of it,0,fL+8 + item n+1 of it,0 & return after hold
  end repeat
  if cz > n then
put item 3 of line -1 of hold - item 1 of line -1 of hold into w
repeat with m = n+1 to cz
  get item 3 of line -1 of hold
  put it,0,w + it,0 & return after hold
end repeat
  end if
  put fL into item 1 of hold
  return hold
end colGuide

David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Reading and writing globals by script

2019-08-10 Thread David Epstein via use-livecode
I want to write a function that will read and write to any named global.  What 
I have below seems to work, but I’m not sure quite why.  Usually, “put gName 
into oldVal” for a global named gName would put the value, not the name, of 
that global into oldVal.  But here it does not.

function globalSwap gName,gVal
   -- Return the existing value of global gName and load gVal into that same 
global
   do "global" && gName
   do "put" && gName && "into oldVal" # "put gName into oldVal" doesn't work 
here.
   do "put gVal into" && gName
   return oldVal
end globalSwap

Is there some way to write this with fewer or no uses of “do”?

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: script for redo/undo text?

2019-07-10 Thread David Epstein via use-livecode
I cannot help with the project of "unlimited" undo/redo, but a simple one-layer 
undo for fields is not hard to implement.  

Sean Cole's suggestion that we should record the field state whenever a key is 
pressed I think does more than is wanted; if you type 10 characters, you don't 
want to choose Undo 10 times to get rid of them.  

My approach is to record the field state on keypresses ONLY if there is a text 
selection (about to be lost when the key is pressed) rather than an insertion 
point.  If text has been added but no text has been lost, you don’t need an 
Undo command to remove what was added.  If you also record the field's state 
before anything is typed in it, and before the Undo command itself is executed, 
and before any scripted handlers change the field, I think this will resemble 
ordinary Word Processor behavior.

on keyDown
  if the selectedText is not empty then uStoreFieldState the short id of the 
selectedField
  pass keyDown
end keyDown
-- and a similar handler for the other keys Sean mentions, although I don't 
think for arrow keys.  

on uStoreFieldState fID -- fID is the short id of the field
  global u
  put the selectedChunk into myChunk
  put fID into u["fieldModified"]
  put the htmlText of fld id fID into u[fID]
  put word 2 of myChunk into u["chunkA"]
  put word 4 of myChunk into u["chunkB"]
end uStoreFieldState

Then on undo, you read the values of u to revise the field, and reload u with 
the state of the field just before undoing.  I store the chunk information so 
that undo can restore the selection as well as the text to its prior state.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: A question about openCard

2019-06-08 Thread David Epstein via use-livecode
Jacqueline is correct:  if I’m not debugging, the execution contexts is not in 
the list of recentCards.
But my palette still does not appear in the list of recentCards.  Further 
testing reveals:  although activating a palette triggers a resumeStack message, 
and leaving a palette triggers a resumeStack message in the stack activated, 
palettes do not get listed in “the recentCards”.
So I think I will resort to a global.  In my main stacks, a resumeStack handler 
should 
— compare the name of this stack with a global “gActiveStack”
— if they are not the same, carry out init actions, and put the name of this 
stack into gActiveStack.
David Epstein

Jacqueline Gay wrote:
I wouldn't expect the execution contexts to be in the list but it sounds 
like that's a result of the debugging process itself. Is it different if 
you just log it to the message box without the debugger?

get the recentCards
put it
... etc

Does the palette not appear anywhere in the list at all?

> On Jun 8, 2019, at 9:13 AM, David Epstein  wrote:
> 
> Several people gave helpful replies to my question, including pointing out 
> that this is a case of “resumeStack”, not “openCard”:
> 
> Is there some simple way that an openCard handler can branch based on what 
> card it is coming from?
> 
> When a user goes to a different card in a stack, or to a different stack, I 
> use an “openCard” handler to set things up.  But I do not want those actions 
> taken if the user is merely “returning” to a card after using a palette tool, 
> or after a palette tool has been opened.
> 
> Jacqueline Gay suggested using the “recentCards” to determine what card the 
> user is coming from.  So I wrote this handler:
> 
> function resumedTheSameCard
>   -- call this in a "resumeStack" handler.
>   -- returns true if palette "tTools" has just been active and the 
> resumeStack message was received by the same card that had been active when 
> that palette was activated.
>   -- returns false if we are coming from a different card, either directly or 
> with a palette activation in between.
>   get the recentCards
>   if the long id of stack "tTools" is not in line 2 of it then return false 
> -- nb should work even if palette "tTools" stack has several cards
>   return line 1 of it = line 3 of it
> end resumedTheSameCard
> 
> But this does not work.  When I debug, I see that line 2 of the recentCards 
> does not refer to a card on my palette stack (“tTools”); it refers instead to 
> a card in the stack “Execution Contexts”.
> 
> Why is that LiveCode system stack appearing in the recentCards, and why is my 
> palette not appearing there?
> 
> Many thanks.
> 
> David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: A question about openCard

2019-06-08 Thread David Epstein via use-livecode
Several people gave helpful replies to my question, including pointing out that 
this is a case of “resumeStack”, not “openCard”:

Is there some simple way that an openCard handler can branch based on what card 
it is coming from?

When a user goes to a different card in a stack, or to a different stack, I use 
an “openCard” handler to set things up.  But I do not want those actions taken 
if the user is merely “returning” to a card after using a palette tool, or 
after a palette tool has been opened.

Jacqueline Gay suggested using the “recentCards” to determine what card the 
user is coming from.  So I wrote this handler:

function resumedTheSameCard
  -- call this in a "resumeStack" handler.
  -- returns true if palette "tTools" has just been active and the resumeStack 
message was received by the same card that had been active when that palette 
was activated.
  -- returns false if we are coming from a different card, either directly or 
with a palette activation in between.
  get the recentCards
  if the long id of stack "tTools" is not in line 2 of it then return false -- 
nb should work even if palette "tTools" stack has several cards
  return line 1 of it = line 3 of it
end resumedTheSameCard

But this does not work.  When I debug, I see that line 2 of the recentCards 
does not refer to a card on my palette stack (“tTools”); it refers instead to a 
card in the stack “Execution Contexts”.

Why is that LiveCode system stack appearing in the recentCards, and why is my 
palette not appearing there?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

A question about openCard

2019-06-02 Thread David Epstein via use-livecode
Is there some simple way that an openCard handler can branch based on what card 
it is coming from?

When a user goes to a different card in a stack, or to a different stack, I use 
an “openCard” handler to set things up.  But I do not want those actions taken 
if the user is merely “returning” to a card after using a palette tool, or 
after a palette tool has been opened.

I’m not sure I understand the full range of events that “close” a card so that 
returning to it triggers “openCard.”  Does this happen if I set an insertion 
point or select text in an unlocked field in a palette, or the user types 
there?  Does it happen if I open a palette, or move a palette, or if the user 
clicks on the palette?

Many thanks.

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Multiple regression in LiveCode?

2019-01-18 Thread DAVID Epstein via use-livecode
Has anyone written a LiveCode function that will take a table of 2 or more 
independent variables and 1 dependent variable, and return coefficients, 
intercept, and standard errors for a multiple regression?


David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Repeat for each line of a variable or field?

2019-01-12 Thread David Epstein via use-livecode
I've done a little bit of speed testing showing extremely slight differences, 
but wonder if anyone who understands the "engine" can advise on this:

Is there a difference between these two approaches?

(1) put fld 1 into txt; repeat for each line k in txt; etc.

and
(2) repeat for each line k in fld 1; etc.

For no very good reason, I tend to do (1), but have begun to wonder:  for a 
very lengthy field 1, does my writing to a variable use up more RAM, and so 
perhaps injure performance?  Or is the engine in effect writing to a variable 
either way?  Is a variable read more quickly than a field?  

Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Large files crash on Windows 10

2018-10-31 Thread DAVID Epstein via use-livecode
Does anyone else have problems dealing with large files on Windows 10?  My main 
LiveCode tool is a stack of about 1.5 MB, and I use it to create, save, and 
open LiveCode stacks that store text and graphics.  These "content" stacks can 
be anywhere from a few kilobytes to 50 MB or more.  On an iMac, these all run 
smoothly.  On Windows 10, my larger content stacks (>10 MB) will sometimes 
close unexpectedly, or crash LiveCode entirely.  The typical trigger is either 
executing a save command, or clicking on a list of cards to navigate to a card 
that contains a large table of text.
Does anyone have relevant experiences or suggested remedies or ways of better 
diagnosing the problem?

Perhaps relevant is that on the Mac I mostly use LC 5.5, on Windows 10 I am 
using LC Community 9.0 (dp4).

Many thanks.
David Epstein

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Area of regular polygon triangles

2018-06-07 Thread David Epstein via use-livecode
While trying Mike Bonner's suggestion of "manual" measuring, I learned the 
answer:  a regular polygon whose official length is L and width is W is 
inscribed in the oval whose length is L and width is W.  So for an equilateral 
triangle the area will be 3/4 * 3^.5 * R^2 (where R = L = W).

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Area of regular polygon triangles

2018-06-06 Thread David Epstein via use-livecode
If a regular polygon has 4 or 8 sides it seems to be inscribed so that all 
points touch the square defined by the object’s height and width, which means 
that it should be fairly easy to deduce the polygon’s area.  
But with 3 sides, the triangle appears slightly smaller than the maximum size 
that could fit into that square.  Is there some math that would give me the 
area of that triangle from the height and width of the square (i.e., the 
official height and width of the polygon object)?
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Text with accented characters

2018-06-03 Thread David Epstein via use-livecode
I am importing some text where certain characters do not look right.  When I 
test their charToNum values I get, for example, 226 and 232.  226 is shown as a 
comma, but should be a lower case a with a circumflex, and 232 is shown as an 
upper case e with an umlaut but should be a lower case e with accent grave.  Is 
there some font I can choose, or some other action I should take, to get these 
(and others) to display properly?
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


HilitedLine of list field lost when unlocked field selected

2018-05-30 Thread David Epstein via use-livecode
This seems like a problem that I’ve solved before, but I can’t recall how.  
With a line hilited in a locked list-behavior-true field, I can use the mouse 
to select text in any of a number of unlocked fields without disturbing my 
list’s hilite.  But if I use the tabKey to move the insertion point or 
selection from one unlocked field to the next, the list hilite is lost.  How 
can I preserve it?

Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: FormattedHeight of a field and its contents

2018-02-02 Thread David Epstein via use-livecode
Thanks for the responses on this.  I used Bernd’s tool and did some more tests, 
and found some things that may be helpful to others.

While the left and right margins of a field are meant literally (a 5 pixel left 
margin leaves 5 white pixels to the left of the text), the top margin is more 
complicated, no doubt owing to the variety of textHeights that need to be 
accommodated.  For example, a margin of "0" will often clip the top of the 
text--as if "0" meant a "negative margin".

6 seems to be a magic default value for a field's top margin, which avoids 
clipping the content.  With horizontal gridlines visible, a 6 pixel buffer 
makes the top row the same height as the other rows.  And with a 6 pixel buffer 
the formattedHeight of the field will exactly match the formattedHeight of the 
field's content (although a non-zero borderwidth or a horizontal scrollbar 
changes this).

Thus--what I wondered about in my original post--with a margin less than 6 the 
formattedHeight of the field is less than the formattedHeight of the content; 
the content is in effect clipped.  At smaller textHeights this will be visible, 
while at larger textHeights only white space above the characters is clipped.

I was trying to answer two questions, and I think I'm pretty close.

1. How do I make sure that the field's contents are all visible if I set the 
field's height to the formattedHeight?  Answer: Set the top and bottom margins 
to 6. For the left and right margins, even 1 pixel should be enough to keep 
everything visible.

2. What margins will provide a symmetrical look for a text box?
A top margin of 6 doesn’t look like a 6 pixel margin; how it looks depends on 
the textHeight.  I estimate that its apparent height is one fourth of the 
effective textHeight, and I use this to size the other margins in the 
“tightMargins” handler below.
While the top margin of 6 looks good with horizontal gridlines, without them 
(and especially if you show a text baseline) it looks too small compared to the 
space between subsequent lines.  To match that larger space, in effect doubling 
the apparent top margin, add one third of the effective textHeight.  See 
“niceMargins” handler below.

Example of usage:
set the margins of fld 1 to the niceMargins of fld 1
set the height of fld 1 to the formattedHeight of fld 1

getProp niceMargins
   put the effective textHeight of the target into t
   put round(t*7/12) into m1
   put round(t/3) into m2
   return m1,6+m2,m1,m1
end niceMargins

getProp tightMargins
   put round(.25*the effective textHeight of the target) into m
   return m,6,m,max(6,m)
end tightMargins

Improvements to these are welcomed.

David Epstein


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

FormattedHeight of a field and its contents

2018-01-31 Thread David Epstein via use-livecode
Is there somewhere an explanation of how a field’s textSize, borderWidth, 
margins, and formattedHeight interact?  

According to the dictionary entry for “formattedHeight”, a field’s 
formattedHeight is calculated “including top and bottom margins”, while the 
formattedHeight of a chunk is calculated “disregarding margins.”

That does not seem consistent with these results for a field whose textSize is 
16 and whose margin is 4:

the formattedHeight of line 1 of fld 1 19
the formattedHeight of line 1 to 2 of fld 1  38
the formattedHeight of fld 1   15  if there’s one 
line of text
the formattedHeight of fld 1   34  if there are two 
lines of text.

Even though there are top and bottom margins of 4, the field’s formattedHeight 
is smaller, rather than larger, than the formattedHeight of its contents.

A perhaps related question:  Why does a field margin of zero clip the visible 
text at the top and left?

Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Identifying empty lines of text

2018-01-12 Thread David Epstein via use-livecode
I use “the number of words in myString = 0” to test whether a line of text 
appears empty, since I want a line with only space characters to be understood 
as empty.
But a line of text I pasted from elsewhere contained an invisible character 
whose charToNum value is 202, and this was counted as a word by my script.
Is there a better way to test for a line of text that has no visible characters?
Many thanks.

David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Auto scrolling a locked field when mouse comes to edge

2017-02-01 Thread David Epstein via use-livecode
To clarify:
For a locked field with autohilite and traversalOn both true, the “built in” 
auto scrolling works the same as with an unlocked field.  I’m looking for a way 
to script this kind of auto scrolling with autohilite and traversalOn both 
false.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Auto scrolling a locked field when mouse comes to edge

2017-02-01 Thread David Epstein via use-livecode
When the mouse drags across text in an unlocked (horizontally and vertically) 
scrolling field, the field automatically scrolls at a legible rate to display 
the (previously hidden) text that the mouse was dragging toward.
Has anyone scripted a way to reproduce this effect for a locked field?
Many thanks.
David Epstein
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode