Can You do this?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

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

Can You do this?

Post by richmond62 » Fri May 10, 2024 12:53 pm

An Answer dialogue:
-
baudrons.png
-
And I mean an Answer Dialogue, NOT a fake one with a substack. 8)

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

Re: Can You do this?

Post by Klaus » Fri May 10, 2024 1:40 pm

Yes, I can! :-D
lc_html.png

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

Re: Can You do this?

Post by Klaus » Fri May 10, 2024 1:45 pm

The magic word is HTML, and LCs Answer dialog supports this.
See screenshot, the name of my image is "band" and the buttons script is just:

Code: Select all

on mouseUp
   put fld 1 into tAnswer
   answer tAnswer with "Yes" or "No"
end mouseUp
lc_html2.png

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 2:32 pm

Klaus.

Amazing. Where in the dictionary does it say that one can do this sort of magic? What is the form of the command itself?

Craig

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

Re: Can You do this?

Post by Klaus » Fri May 10, 2024 2:38 pm

Hi Craig,

the dictionary only states:
...
The prompt can be either formatted text (in the property's format) or plain text. If the prompt contains <p> or a start/end tag pair, the answer command assumes the text is in the same format as the property. Otherwise, the answer command assumes the text is plain text.
...
But since LC supports a small subset of html I simply tried this with an image.
Et voila, it works! :-)

Best

Klaus

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 4:38 pm

Klaus.

Terrific detective work and lucky gamble both. I wonder where else this can be exploited.

Craig

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 4:39 pm

HOW COULD THEY NOT mention this somewhere? It would be a fabulous addition to who knows how many LC gadgets.

Craig

stam
Posts: 2736
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Can You do this?

Post by stam » Fri May 10, 2024 7:19 pm

dunbarx wrote:
Fri May 10, 2024 4:39 pm
HOW COULD THEY NOT mention this somewhere? It would be a fabulous addition to who knows how many LC gadgets.

Craig
I'm guessing that by the time you've made the image the right size, positioned everything as you want and then have to keep doing this for every image, you're probably better off designing a substack of your own. And it would probably look a whole lot better since you'd control the layout directly...

Or to put it differently - why is this better than a substack presented as modal?
The coding would be trivial and you wouldn't be constrained by the limits of the answer dialog...

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 7:54 pm

Stam.

Could not agree more. But where else might it be possible to insert an image where before I (we?) only assumed text could go?

I still have not heard from Klaus on what might be a single line of code that placed that image into the dialog.

Craig

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

Re: Can You do this?

Post by Klaus » Fri May 10, 2024 8:45 pm

Craig, this is pure HTML code:

Code: Select all

<p>Do you like this band?</p>
<p><img src="band"></p>
See the second line, which refers to the image on the current card named "band"
and this is the html tag which does the magic: <img src="band">
I was also very surprised that this actually works. :-)

On the other hand, <img src... is a VERY basic html tag.

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 9:05 pm

Klaus.

Recall I am only a beginner.

How do you use that to invoke an answer dialog with an image? I tried several ways with my own resident image, and nothing works. :oops:

Craig

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

Re: Can You do this?

Post by dunbarx » Fri May 10, 2024 9:06 pm

This part of the dictionary only makes it worse:
On OS X systems, the image specified in the gRevAppIcon variable appears as the application icon in the answer dialog box (unless the answer...as sheet form is used). If you specify an iconType, the image specified in the gRevSmallAppIcon variable is used instead, along with the special icon specified by the iconType.
I got as far as "On OS X systems, the image specified in the..."

Craig

stam
Posts: 2736
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Can You do this?

Post by stam » Sat May 11, 2024 7:15 am

dunbarx wrote:
Fri May 10, 2024 7:54 pm
Stam.

Could not agree more. But where else might it be possible to insert an image where before I (we?) only assumed text could go?

I still have not heard from Klaus on what might be a single line of code that placed that image into the dialog.

Craig
I know what you mean, but in my mind just because you can doesn’t mean you should ;)

I have certainly used basic html in answer dialogs for styling… I’ll admit it never occurred to me to add an image tag, because that would be highly atypical for such a dialog, so I never felt the need to test it.

If I need to present an image dialog with custom image(s) to the user I’ll just substack it so I have full layout control.

Perhaps Richmond can elaborate on the point of this?

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

Re: Can You do this?

Post by richmond62 » Sat May 11, 2024 7:59 am

Richmond had drunk 4 glasses of strong red wine and his mind was wandering.

However, the 'problem' about using a substack as an answer palette is that it can get obscured by other substacks unless one is very careful.

In my Devawriter I use images in the main stack and set the visible when they are needed: the snag about this is that one needs one of these images on every card where you might want them displayed.

Certainly:

1. An Answer/Ask palette without an IDE logo is, as far as I'm concerned a big plus.

2. An Answer/Ask palette with a bespoke logo is, as far as I'm concerned a big plus.

3. The logical extension of #2 is an image or a set of images.

Klaus's solution is, like the vast majority of Klaus's solutions, really marvellous.

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

Re: Can You do this?

Post by richmond62 » Sat May 11, 2024 9:38 am

I wonder how far one can 'push' the HTML-code?
-
bunny.png
-
This did not work:
-
Screenshot 2024-05-11 at 11.42.10.png

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”