~theclapp


#142 widget/editor.Move on an editor that hasn't been laid out yet panics 14 days ago

Comment by ~theclapp on ~eliasnaur/gio

Thanks!

#142 widget/editor.Move on an editor that hasn't been laid out yet panics 15 days ago

Ticket created by ~theclapp on ~eliasnaur/gio

If you call Move on an editor that hasn't been laid out yet, it panics, because editor.shaper is nil.

In my app, I have occasion to set the editor text, and move the caret to the end of the text (Move(len(text))), before having actually run Layout the first time.

#19 Add multiple top-level windows a month ago

Comment by ~theclapp on ~eliasnaur/gio

Thanks!

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Comment by ~theclapp on ~eliasnaur/gio

Nice. Thanks!

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Comment by ~theclapp on ~eliasnaur/gio

That looks like it'd work.

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Comment by ~theclapp on ~eliasnaur/gio

Yeah, confirmed, this works:

func IsChecked(c widget.CheckBox) bool {
	return c.Checked(layout.NewContext(nil))
}

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Comment by ~theclapp on ~eliasnaur/gio

use-case

I want to do something when the checkbox changes from unchecked to checked, or back again. Specifically, I have a list of checkboxes, and a "select all" checkbox, and when you click "select all" I want to set all the others to "checked", and when you click it again, I'd like to set all the others to "unchecked". Setting them all is not a hugely expensive operations, but on the other hand it's not something I want to do on every layout if I don't have to.

Button & RadioButton

I haven't used them in that way, but from checking the code, it looks like they'd have the same problem, yeah.

If I planned ahead and had a Context with an empty event queue, I guess I could use that instead. (But, ew.) Or if you changed the event processing code to allow for a nil Context, that could work too. (Less but non-zero ew.) If you exported the queue field of Context then I could copy my regular context and clear Queue right where I use it, which wouldn't require as much planning ahead.

Hmmm, actually typing that out and looking at the code some more, I guess I could do that regardless. My hurdle was the assumption that I'd want an otherwise identical Context, and to set the cfg correctly I'd have to have set up my alternate context in the main loop, but it looks like if I just want an empty event list (and don't care about cfg), I'm pretty sure I could just call NewContext(nil) and use that. That still seems suboptimal; since the checkbox knows its state, why can't I just query it, you know?

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Comment by ~theclapp on ~eliasnaur/gio

Oops, CheckBox.click not clicked. Also CheckBox not Checkbox.

#96 Can't check the state of a checkbox w/out processing events 2 months ago

Ticket created by ~theclapp on ~eliasnaur/gio

The only way to check the state of a checkbox is to call checkbox.Checked(gtx), which processes any new events for the checkbox, and returns the state. This means that if you want to know whether the checkbox changed state during a particular layout or whatever, you have to track its state externally.

If you export Checkbox.checked then that wouldn't be necessary. (You can't export it as-is, because there's already a Checkbox.Checked() method, so you'd have to call it something else (like IsChecked, perhaps), or rename Checked().)

While you're at it, if you export Checkbox.clicked, then you'll make it possible for people to check modifier keys on the mouse click.

#94 Space layouting. 3 months ago

Comment by ~theclapp on ~eliasnaur/gio

For your spacer, would this work?

layout.Rigid(func() { gtx.Dimensions.Size = image.Point{X: ..., Y: ...} // dimensions of desired space }),

Or also check out how Inset is implemented. In particular, op.TransformOp{}.Offset() might do what you want.