GTKD - Attach Button to Grid in specific column and row
Mike Wey via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 11 14:14:43 PDT 2016
On 06/11/2016 04:57 PM, TheDGuy wrote:
> Hi,
> i am wondering why this code doesn't work, even though i set the column
> and row position of the button it is always placed at the top left (so
> basically first row and first column):
>
> ... Code ...
The way GTK manages width and height, usually widgets are given the
minimum size they need. So when the button is the only widget in the
grid the other rows and columns have a height/width of 0.
You can force the button / gird cell to the bottom left by setting the
expand and alignment properties of the button.
this(int width, int height, string title){
super(title);
setDefaultSize(width,height);
Button btn = new Button();
btn.setSizeRequest(25,25);
btn.setLabel("Exit");
btn.setVexpand(true);
btn.setHexpand(true);
btn.setHalign(Align.END);
btn.setValign(Align.END);
auto call = &enterEvent;
btn.addOnEnterNotify(call);
btn.addOnLeaveNotify(call);
Grid grid = new Grid();
grid.setColumnSpacing(6);
grid.setRowSpacing(6);
grid.attach(btn,3,3,1,1);
add(grid);
showAll();
}
--
Mike Wey
More information about the Digitalmars-d-learn
mailing list