Set the imagesource of a character to a built in graphic

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
I am trying this:

set the imageSource of char 1 of line 1 of field "Scrolling List Field" to image ID 200086

No workie. How do I refer to a built in graphic? I use this to refer to imported graphics.

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
NVM I figured it out.

Bob S


> On Jun 23, 2017, at 16:19 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> I am trying this:
>
> set the imageSource of char 1 of line 1 of field "Scrolling List Field" to image ID 200086
>
> No workie. How do I refer to a built in graphic? I use this to refer to imported graphics.
>
> Bob S

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
Okay so here is an odd thing. Given that the imageSource of char 1 of eack line of a scrolling field is set to a graphic (A plus sign in this case):

on selectionChanged
   put the clickChar into tChar
   if tText is not space then exit selectionChanged

   put word 2 of the clickLine into tLine
   put the buttonlist of me into aButtonList -- an array
   put aButtonList ["buttonNames"] into tButtonList -- contains names of 3 buttons each line preceded by 2 tabs
   
   if tButtonList is not in me then
      put tButtonList before line tLine+1 of me -- works great!
   else
      replace tButtonList with empty in me -- removes the imageSource on char 1 of every line
   end if
end selectionChanged


This works, but on the second click it replaces the imageSource on every line. That shouldn't happen should it??

Bob S


> On Jun 23, 2017, at 16:23 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> NVM I figured it out.
>
> Bob S
>
>
>> On Jun 23, 2017, at 16:19 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>>
>> I am trying this:
>>
>> set the imageSource of char 1 of line 1 of field "Scrolling List Field" to image ID 200086
>>
>> No workie. How do I refer to a built in graphic? I use this to refer to imported graphics.
>>
>> Bob S
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
That should read
put the clickChar into tChar
if tTchar is not space...

Doesn't affect the problem tho

Bob S




> On Jun 23, 2017, at 16:48 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
>   put the clickChar into tChar


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
On 6/23/17 6:48 PM, Bob Sneidar via use-livecode wrote:

> Okay so here is an odd thing. Given that the imageSource of char 1 of eack line of a scrolling field is set to a graphic (A plus sign in this case):
>
> on selectionChanged
>     put the clickChar into tChar
>     if tText is not space then exit selectionChanged
>
>     put word 2 of the clickLine into tLine
>     put the buttonlist of me into aButtonList -- an array
>     put aButtonList ["buttonNames"] into tButtonList -- contains names of 3 buttons each line preceded by 2 tabs
>    
>     if tButtonList is not in me then
>        put tButtonList before line tLine+1 of me -- works great!
>     else
>        replace tButtonList with empty in me -- removes the imageSource on char 1 of every line
>     end if
> end selectionChanged
>
>
> This works, but on the second click it replaces the imageSource on every line. That shouldn't happen should it??

ImageSource is sort of like text styles, you can see it most clearly in
the htmlText of a field. An imageSource is represented by tags just like
bold, italic, and other styles. You'd see the same behavior if the lines
were bold instead of having an imageSource.

Inserting some lines into a field doesn't change the styling of the
other lines, it just adds some additional unstyled text.

The replace command works only on plain text and in this case the script
is passing the entire content of the field. The replace command gets the
full text, does the replacement, and puts the text back. As far as it's
concerned, the imageSource characters are just spaces. Styling tags are
ignored and consequently stripped out.

You can either get the lineOffset of the unwanted lines and delete only
those, which leaves the htmlText intact elsewhere, or you could get the
htmlText of the field, do the replacement, and then set the field's
htmlText to the revised content.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
There's a form of replace which preserves styling in fields these days (an FE we ran quite a while ago) - take a look at the replace entry in the dictionary.

Warmest Regards,

Mark

Sent from my iPhone

> On 24 Jun 2017, at 07:14, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
>> On 6/23/17 6:48 PM, Bob Sneidar via use-livecode wrote:
>> Okay so here is an odd thing. Given that the imageSource of char 1 of eack line of a scrolling field is set to a graphic (A plus sign in this case):
>> on selectionChanged
>>    put the clickChar into tChar
>>    if tText is not space then exit selectionChanged
>>    put word 2 of the clickLine into tLine
>>    put the buttonlist of me into aButtonList -- an array
>>    put aButtonList ["buttonNames"] into tButtonList -- contains names of 3 buttons each line preceded by 2 tabs
>>        if tButtonList is not in me then
>>       put tButtonList before line tLine+1 of me -- works great!
>>    else
>>       replace tButtonList with empty in me -- removes the imageSource on char 1 of every line
>>    end if
>> end selectionChanged
>> This works, but on the second click it replaces the imageSource on every line. That shouldn't happen should it??
>
> ImageSource is sort of like text styles, you can see it most clearly in the htmlText of a field. An imageSource is represented by tags just like bold, italic, and other styles. You'd see the same behavior if the lines were bold instead of having an imageSource.
>
> Inserting some lines into a field doesn't change the styling of the other lines, it just adds some additional unstyled text.
>
> The replace command works only on plain text and in this case the script is passing the entire content of the field. The replace command gets the full text, does the replacement, and puts the text back. As far as it's concerned, the imageSource characters are just spaces. Styling tags are ignored and consequently stripped out.
>
> You can either get the lineOffset of the unwanted lines and delete only those, which leaves the htmlText intact elsewhere, or you could get the htmlText of the field, do the replacement, and then set the field's htmlText to the revised content.
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
On 6/24/17 6:12 AM, Mark Waddingham via use-livecode wrote:
> There's a form of replace which preserves styling in fields these days (an FE we ran quite a while ago) - take a look at the replace entry in the dictionary.

That's great! I must have missed that revision. Very useful.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Thanks Mark. That solves half the problem. I would have to know the actual character of the cr before the line I am trying to insert text before to do something like

put "this is a test" & cr before line 3 of field "Scrolling List Field"

I can work around it I am sure. As long as I know that what I am seeing is not a bug, but is the way the vanilla replace command works, I won't go barking up trees.

Bob S


> On Jun 24, 2017, at 04:12 , Mark Waddingham via use-livecode <[hidden email]> wrote:
>
> There's a form of replace which preserves styling in fields these days (an FE we ran quite a while ago) - take a look at the replace entry in the dictionary.
>
> Warmest Regards,
>
> Mark
>
> Sent from my iPhone


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
Ok so no combination of replace in field will allow me to put something before or after a line without borking the imagedata. The only way to do it is to reapply the imageData each time I touch the field text. I was hoping to come up with some king of widget eventially that allowed you to manipulate an expanding list to show and hide subMenu items.

If no one else has done this already, I will just hack one out.

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
The tree widget might be useful here. Alternately, don't use replace, use
text chunking instead to add or remove lines.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com



On June 26, 2017 10:24:11 AM Bob Sneidar via use-livecode
<[hidden email]> wrote:

> Ok so no combination of replace in field will allow me to put something
> before or after a line without borking the imagedata. The only way to do it
> is to reapply the imageData each time I touch the field text. I was hoping
> to come up with some king of widget eventially that allowed you to
> manipulate an expanding list to show and hide subMenu items.
>
> If no one else has done this already, I will just hack one out.
>
> Bob S
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Eventually you are showing/hiding lines, so:

Did you already try to use the hidden property?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
Oh nice I didn't know a line of text could be hidden! I will check that out. Meanwhile I got it working right by using htmlText. :-)

Bob S


> On Jun 26, 2017, at 09:10 , hh via use-livecode <[hidden email]> wrote:
>
> Eventually you are showing/hiding lines, so:
>
> Did you already try to use the hidden property?


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
That does indeed work and is a lot cleaner.

Bob S


> On Jun 26, 2017, at 09:11 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> Oh nice I didn't know a line of text could be hidden! I will check that out. Meanwhile I got it working right by using htmlText. :-)
>
> Bob S
>
>
>> On Jun 26, 2017, at 09:10 , hh via use-livecode <[hidden email]> wrote:
>>
>> Eventually you are showing/hiding lines, so:
>>
>> Did you already try to use the hidden property?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
Can you supply a code sample of hiding a line of text in a list?

Sincerely,

Clarence Martin
Email: [hidden email]
Cell: 626 6965561

-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf
Of Bob Sneidar via use-livecode
Sent: Monday, June 26, 2017 9:24 AM
To: How to use LiveCode <[hidden email]>
Cc: Bob Sneidar <[hidden email]>
Subject: Re: Set the imagesource of a character to a built in graphic

That does indeed work and is a lot cleaner.

Bob S


> On Jun 26, 2017, at 09:11 , Bob Sneidar via use-livecode
<[hidden email]> wrote:
>
> Oh nice I didn't know a line of text could be hidden! I will check that
out. Meanwhile I got it working right by using htmlText. :-)
>
> Bob S
>
>
>> On Jun 26, 2017, at 09:10 , hh via use-livecode
<[hidden email]> wrote:
>>
>> Eventually you are showing/hiding lines, so:
>>
>> Did you already try to use the hidden property?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
I looked at the widget. Not sure how to use it. I got an object with a + control which apparently creates custom property keys and displays it in the field. I could probably make that work, but I probably won't have a lot of control over the appearance. I got the thing working by manipulating the HTML text.

The goal will be to create an object library where I can select an object, be it a group, button, field or menu (I know it's a glorified button) and then in a palette add that object to a list where each object class is expandable/collapsable.

I have certain fields and buttons which have custom scripts and properties which control how they behave in my apps. I am trying to create a kind of Library app that will allow me to change a few settings then "drop" the object onto a card.

I will have to be able to add and delete objects to this list, while copying the actual object to the library somehow. If it works the way I would like, I will be able to create and customize objects one time, then drop them any number of times.

Behaviors work well for scripts, but there is no "behaviors" for properties. I suppose they would be called "templates" if they existed. I suppose I could simply provide a list of properties and let the user check off the ones they want to include in a "template" but there are so many properties this would become cumbersome pretty quickly. Also, that would not handle more complex objects like groups.

Bob S



> On Jun 26, 2017, at 08:38 , J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> The tree widget might be useful here. Alternately, don't use replace, use text chunking instead to add or remove lines.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
set the hidden of line 1 to  3 of field "myField" to true -- only works with fields not text in variables

Bob S


> On Jun 26, 2017, at 09:46 , ** Clarence P Martin ** via use-livecode <[hidden email]> wrote:
>
> Can you supply a code sample of hiding a line of text in a list?
>
> Sincerely,
>
> Clarence Martin


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Mark Waddingham wrote:

 > There's a form of replace which preserves styling in fields these days
 > (an FE we ran quite a while ago) - take a look at the replace entry in
 > the dictionary.

It works seemingly well, even with chunk expressions, e.g.:

   replace "i" with "X" in line 1 of fld 1 preserving styles

But I found it also does something very weird:  in my test the
imageSource was applied to the first "i" in the field, and after the
replace command there was now an "X" immediately before the rendered image.

So while it was good to see the image still rendered, if the "i" was now
replaced with "X" and the "X" is visible, what is the imageSource
attached to?

It seems it's attached to nothing.  Getting the htmlText of the field
after the replace command shows no <img> tag at all.

Reported, with sample stack:
http://quality.livecode.com/show_bug.cgi?id=19956

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
OK, I didn't know about the paragraph property.

set the visible of paragraph 2 of fld "fldList" to false
 this does make a line disappear, but apparently keeps the value in memory
so that it can be restored.

Sincerely,

Clarence Martin
Email: [hidden email]
Cell: 626 6965561

-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf
Of ** Clarence P Martin ** via use-livecode
Sent: Monday, June 26, 2017 9:46 AM
To: 'How to use LiveCode' <[hidden email]>
Cc: ** Clarence P Martin ** <[hidden email]>
Subject: RE: Set the imagesource of a character to a built in graphic

Can you supply a code sample of hiding a line of text in a list?

Sincerely,

Clarence Martin
Email: [hidden email]
Cell: 626 6965561

-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf
Of Bob Sneidar via use-livecode
Sent: Monday, June 26, 2017 9:24 AM
To: How to use LiveCode <[hidden email]>
Cc: Bob Sneidar <[hidden email]>
Subject: Re: Set the imagesource of a character to a built in graphic

That does indeed work and is a lot cleaner.

Bob S


> On Jun 26, 2017, at 09:11 , Bob Sneidar via use-livecode
<[hidden email]> wrote:
>
> Oh nice I didn't know a line of text could be hidden! I will check
> that
out. Meanwhile I got it working right by using htmlText. :-)
>
> Bob S
>
>
>> On Jun 26, 2017, at 09:10 , hh via use-livecode
<[hidden email]> wrote:
>>
>> Eventually you are showing/hiding lines, so:
>>
>> Did you already try to use the hidden property?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Richard, that is kind of what I was seeing with replace in field. Very dicey. So I decided to see if I could use the hidden propery method to work. Here is what I came up with. Remember that char 1 of the 1st level lines are spaces, and the 1st char spaces in those lines have the imageData set to a + graphic so clicking on the + will expand and collapse the line. The second level lines do not start with spaces, so I can use that to discriminate between first level lines and others (I supose I could have checked for the imageData but what the hell):

on mouseUp
   put the clickChar into tChar
   if tChar is not space then exit mouseUp
   put word 2 of the clickLine into tLine -- the line number of the line clicked
   put the text of me into tText
   put tLine +1 into tStartLine

   repeat with i = tStartLine to the number of lines of tText
      if char 1 of line i of tText is space then
         exit repeat
      end if

      put i into tEndLine
   end repeat
   
   if char 1 of line tEndLine of me is space then exit mouseUp -- there are no sub-lines

   if the hidden of line tStartLine to tEndLine of me is true then
      set the hidden of line tStartLine to tEndLine of me to false
   else
      set the hidden of line tStartLine to tEndLine of me to true
   end if
end mouseUp

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set the imagesource of a character to a built in graphic

Mark Waddingham via use-livecode
In reply to this post by Mark Waddingham via use-livecode
Bob S. wrote:
"if the hidden of line tStartLine to tEndLine of me is <false/true>
then set the hidden of line tStartLine to tEndLine of me to <true|false>"

Yes, but depends on the scenario: Sometimes I find it more safe to walk
through the range (for j=tStartLine to tEndLine) and check the hidden
of each single line, because the hidden of a range may have been changed
by changing the range elsewhere.

Also: Did you already try to use the metadata property for a chunk instead
of relying on spaces?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12
Loading...