2
$\begingroup$

I would like to use an image as a ClickPane, inside a column. I want the image to appear at its native size.

Outside of the column, this works:

size = 256;
image = ConstantImage[.5, {size, size}];
DynamicModule[{},
 ClickPane[image, (Print[#]) &]
 ]

But when I put the ClickPane inside a Column, it always displays as a small size, regardless of the value of size.

size = 256;
image = ConstantImage[.5, {size, size}];
DynamicModule[{},
 Column[{ClickPane[image,
    (pt = #) &], Dynamic@pt}, ItemSize -> Full]
 ]

I have tried different values for ItemSize but nothing seems to have an effect.

How can I force the image to appear at its native size?

$\endgroup$
1
  • 2
    $\begingroup$ Add an explicit ImageSize to ConstantImage or wrap it in Image[image, ImageSize->{size, size}] By default that is set to Automatic to allow for this kind of context-based resizing $\endgroup$
    – b3m2a1
    Apr 8, 2020 at 2:45

1 Answer 1

1
$\begingroup$

I think that you are looking for : Style[..., ImageSizeMultipliers -> {1, 1}]

size = 256;
image = ConstantImage[.5, {size, size}];
DynamicModule[{},
 Style[#, ImageSizeMultipliers -> {1, 1}] & @
   Column[{ClickPane[image, (pt = #) &], Dynamic@pt}, 
   ItemSize -> Full]]  

enter image description here

Compare with :

size = 256;
image = ConstantImage[.5, {size, size}];
DynamicModule[{}, ClickPane[image, (Print[#]) &]]  

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.