1
$\begingroup$

I am trying to find a way to have an item in a grid cell that always fill the available vertical space enforced by the remaining items (without enforcing any row height itself).

One of my (many) failed attempts:

Grid[{{
   Item[
    Style[
     Pane["", ImageSize -> {Scaled@1, Full}],
     Background -> Green
     ],
    ItemSize -> {1, Full}
    ],
   Style[
    Pane["", ImageSize -> {10, 200}],
    Background -> Yellow
    ]
   }},
 Frame -> All,
 Spacings -> 0
 ]

enter image description here

The green rectangle is supposed to fill the left cell entirely (and adjust its size if the size of the yellow rectangle is changed).

Update: The end goal of this is to have a cell-filling EventHandler expression. So anything of the form Grid[{{EventHandler[…], …}}, …] works for me, as long as the EventHandler fills the whole cell.

Is something like this possible?

$\endgroup$
  • $\begingroup$ if we are allowed to cheat: Grid[{{Item[ Button["", None, Appearance -> "FramedPalette", Background -> Green], ItemSize -> {1, Full}], Style[Pane["", ImageSize -> {10, 200}], Background -> Yellow]}}, Frame -> All, Spacings -> 0]? $\endgroup$ – kglr Jan 22 at 22:34
  • $\begingroup$ @kglr That's almost perfect, thanks! Any idea how to get rid of the frame that appears when hovering over the button? Sadly, changing the Appearance of the button to None seems to break the auto-sizing property of the button. (An explicit ImageSize -> Full doesn't seem to help either...) $\endgroup$ – Lukas Lang Jan 23 at 8:54
  • $\begingroup$ I guess adding Enabled->False to the button and wrapping it in EventHandler does the trick, although it seems a bit hacky... Can you post your comment as an answer so I can accept it? $\endgroup$ – Lukas Lang Jan 23 at 9:16
  • $\begingroup$ Lukas, posted the comment as an answer. (Not sure about the EventHandler bit.) $\endgroup$ – kglr Jan 23 at 13:48
1
$\begingroup$
Grid[{{Item[Button["", None, Appearance -> "Palette", Enabled -> False, 
     Background -> Green], ItemSize -> {1, Full}], 
   Style[Pane["", ImageSize -> {10, 200}], Background -> Yellow]}}, 
 Frame -> All, Spacings -> 0]

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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