Jump to content

Image area or region


NizamUlMulk

Recommended Posts

How is possible define areas or regions in a TUniImage?

Ex.. Show some flags in an unique picture, and when click in each flag do something ... as redirect to another form, or another website ... 

 

Or better, show a image map (as attached), and click in a country for do something

In HTML is there map and area tags ... but ... never must change size of controls to make it works

post-2027-0-17840000-1516361705_thumb.jpg

Link to comment
Share on other sites

An idea / a mailla (squares) with images (puzzle) :

 

1. Put 9 uniContainers (mailla) on a form :

3 horizontal uniContainers (square),

And 3 others (seconde line)

And 3 others (third line).

 

2. Use a graphical software like CorelDraw to cut countries from ther continent.

This pieces are squares and have the same size.

 

3. Paste these images on your Unicontaners.

 

4. Generate your click event on each unicontainer.

 

Regards.

Link to comment
Share on other sites

  • 1 month later...

What would really work would be an extended TUniImage that supports the addition of the "usemap" attribute and the addition of a HTML Map tag with Areas.

 

I've figured out how to manually add this to a TUniImage:

 

function afterrender(sender, eOpts)

{
  document.getElementById(sender.el.id).getElementsByTagName('img')[0].setAttribute("usemap","#ImageMap");
  document.getElementById(sender.el.id).innerHTML = document.getElementById(sender.el.id).innerHTML + '
  <map name="ImageMap">
    <area shape="rect" coords="0,0,82,126" href="#">
  </map>
  ';
document.getElementById(sender.el.id).getElementsByTagName('map')[0].getElementsByTagName('area')[0].onclick=function() {
  window.alert('clicked');
  return false; // returning false stops the link being followed
}  
   
}
 
It wouldn't be too hard to create a TUniImage descendant that could store a hotspot list (rectangles, circles and poly) and fire an event.  The time consuming part would be building a hotspot property editor to visually build the hotspot list.
 
I'll add it to my ToDo List :)
Link to comment
Share on other sites

OK... I'm actually trying to build this component (TUniMappedImage)  With a property editor to visually define hotspot areas (rect, circle and poly)

I'm descending from TUniImage - 

 

In Designer, I'd like to be able to visually show the hotspots, draw them on the canvas... I don't want to do this at all for the runtime web version... 

 

I know that UniGui is designed to separate design from runtime but... 

 

How do I use the VCLControlClassName method override to supply a designer only version for display?

 

I can see that TUniImage uses "TVCLImage" which I assume does the painting for the design time display of the component... but I don't have the source for that class to be able to create a descendant.  

 

I've tried creating a new vcl class descended from TImage (in the same unit) and using that in a VCLControlClassName override method but it does not seem to work.

 

Any ideas?

Link to comment
Share on other sites

  • 1 year later...
On 2/27/2018 at 8:22 AM, Daryl McMurray said:

OK... I'm actually trying to build this component (TUniMappedImage)  With a property editor to visually define hotspot areas (rect, circle and poly)

I'm descending from TUniImage - 

 

In Designer, I'd like to be able to visually show the hotspots, draw them on the canvas... I don't want to do this at all for the runtime web version... 

 

I know that UniGui is designed to separate design from runtime but... 

 

How do I use the VCLControlClassName method override to supply a designer only version for display?

 

I can see that TUniImage uses "TVCLImage" which I assume does the painting for the design time display of the component... but I don't have the source for that class to be able to create a descendant.  

 

I've tried creating a new vcl class descended from TImage (in the same unit) and using that in a VCLControlClassName override method but it does not seem to work.

 

Any ideas?

did you created it, or you have another solution could you share it's code please?

Link to comment
Share on other sites

On 2/21/2018 at 2:42 AM, Daryl McMurray said:

What would really work would be an extended TUniImage that supports the addition of the "usemap" attribute and the addition of a HTML Map tag with Areas.

 

I've figured out how to manually add this to a TUniImage:

 

function afterrender(sender, eOpts)

{
  document.getElementById(sender.el.id).getElementsByTagName('img')[0].setAttribute("usemap","#ImageMap");
  document.getElementById(sender.el.id).innerHTML = document.getElementById(sender.el.id).innerHTML + '
  <map name="ImageMap">
    <area shape="rect" coords="0,0,82,126" href="#">
  </map>
  ';
document.getElementById(sender.el.id).getElementsByTagName('map')[0].getElementsByTagName('area')[0].onclick=function() {
  window.alert('clicked');
  return false; // returning false stops the link being followed
}  
   
}
 
It wouldn't be too hard to create a TUniImage descendant that could store a hotspot list (rectangles, circles and poly) and fire an event.  The time consuming part would be building a hotspot property editor to visually build the hotspot list.
 
I'll add it to my ToDo List :)

anther problem the responsive not working , i mean if resizing the image the area posisions changed

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...