()
| 194 | } |
| 195 | |
| 196 | func (tr *Tree) Init() { |
| 197 | tr.WidgetBase.Init() |
| 198 | tr.AddContextMenu(tr.contextMenu) |
| 199 | tr.IconOpen = icons.KeyboardArrowDown |
| 200 | tr.IconClosed = icons.KeyboardArrowRight |
| 201 | tr.IconLeaf = icons.Blank |
| 202 | tr.OpenDepth = 4 |
| 203 | tr.Styler(func(s *styles.Style) { |
| 204 | // our parts are draggable and droppable, not us ourself |
| 205 | s.SetAbilities(true, abilities.Activatable, abilities.Focusable, abilities.Selectable, abilities.Hoverable) |
| 206 | tr.Indent.Em(1) |
| 207 | s.Border.Style.Set(styles.BorderNone) |
| 208 | s.Border.Radius = styles.BorderRadiusFull |
| 209 | s.MaxBorder = s.Border |
| 210 | // s.Border.Width.Left.SetDp(1) |
| 211 | // s.Border.Color.Left = colors.Scheme.OutlineVariant |
| 212 | s.Margin.Zero() |
| 213 | s.Padding.Left.Dp(ConstantSpacing(4)) |
| 214 | s.Padding.SetVertical(units.Dp(4)) |
| 215 | s.Padding.Right.Zero() |
| 216 | s.Text.Align = styles.Start |
| 217 | |
| 218 | // need to copy over to actual and then clear styles one |
| 219 | if s.Is(states.Selected) { |
| 220 | // render handles manually, similar to with actStateLayer |
| 221 | s.Background = nil |
| 222 | } else { |
| 223 | s.Color = colors.Scheme.OnSurface |
| 224 | } |
| 225 | }) |
| 226 | tr.FinalStyler(func(s *styles.Style) { |
| 227 | tr.actStateLayer = s.StateLayer |
| 228 | s.StateLayer = 0 |
| 229 | }) |
| 230 | |
| 231 | // We let the parts handle our state |
| 232 | // so that we only get it when we are doing |
| 233 | // something with this tree specifically, |
| 234 | // not with any of our children (see OnChildAdded). |
| 235 | // we only need to handle the starting ones here, |
| 236 | // as the other ones will just set the state to |
| 237 | // false, which it already is. |
| 238 | tr.On(events.MouseEnter, func(e events.Event) { e.SetHandled() }) |
| 239 | tr.On(events.MouseLeave, func(e events.Event) { e.SetHandled() }) |
| 240 | tr.On(events.MouseDown, func(e events.Event) { e.SetHandled() }) |
| 241 | tr.OnClick(func(e events.Event) { e.SetHandled() }) |
| 242 | tr.On(events.DragStart, func(e events.Event) { e.SetHandled() }) |
| 243 | tr.On(events.DragEnter, func(e events.Event) { e.SetHandled() }) |
| 244 | tr.On(events.DragLeave, func(e events.Event) { e.SetHandled() }) |
| 245 | tr.On(events.Drop, func(e events.Event) { e.SetHandled() }) |
| 246 | tr.On(events.DropDeleteSource, func(e events.Event) { e.SetHandled() }) |
| 247 | tr.On(events.KeyChord, func(e events.Event) { |
| 248 | kf := keymap.Of(e.KeyChord()) |
| 249 | selMode := events.SelectModeBits(e.Modifiers()) |
| 250 | if DebugSettings.KeyEventTrace { |
| 251 | slog.Info("Tree KeyInput", "widget", tr, "keyFunction", kf, "selMode", selMode) |
| 252 | } |
| 253 |
nothing calls this directly
no test coverage detected