Exemple #1
0
        public ThemedNumericEditBox()
        {
            ThemedEditBox.Decorate(this);
            MinWidth           = 0.0f;
            MaxWidth           = 105.0f;
            TextWidget.Padding = new Thickness(left: 5.0f, right: 5.0f, top: 2.0f, bottom: 2.0f);
            Layout             = new HBoxLayout();
            // Lime.EditorParams.MouseSelectionThreshold is 3 by default and this gesture should be recognized first.
            // To achieve that we're setting its drag threshold to 2.0f, add it to Editor.ClickableWidget (same collection
            // editor adds its widgets to) and do it in LateTasks.
            var dragGesture = new DragGesture(exclusive: true, dragThreshold: 2.0f);

            Updated += (delta) => {
                if (Editor.FocusableWidget.IsFocused())
                {
                    dragGesture.Cancel();
                }
                else if (IsMouseOverThisOrDescendant() || isDragging)
                {
                    WidgetContext.Current.MouseCursor = MouseCursor.SizeWE;
                }
            };
            LateTasks.Add(Task.Repeat(() => {
                dragGesture.Recognized += () => Tasks.Add(SpinByDragTask(dragGesture));
                Editor.ClickableWidget.Gestures.Insert(0, dragGesture);
                return(false);
            }));
        }
Exemple #2
0
 public ThemedNumericEditBox()
 {
     ThemedEditBox.Decorate(this);
     MinMaxWidth        = 80;
     TextWidget.Padding = new Thickness(2);
     Layout             = new HBoxLayout();
     Nodes.Insert(0, CreateSpinButton(SpinButtonType.Subtractive));
     Nodes.Add(CreateSpinButton(SpinButtonType.Additive));
 }