Skip to main content
Light Dark System

Button Scroll

<et2-button-scroll> | Et2ButtonScroll

Overview

Up / Down spinner buttons are used to adjust a value by a set amount

Examples

A pair of stacked up / down buttons. It has no value and no idea what it is next to - all it does is emit et2-scroll with detail 1 for up and -1 for down, and leave the arithmetic to you. That is the point: the same widget steps a number, a date, a page number or a position in a list, depending on what the thing it is slotted into does with the event.

Stepping a value

Put it in an input’s suffix slot and handle et2-scroll.

<et2-textbox id="scroll-example" value="10">
    <et2-button-scroll slot="suffix"></et2-button-scroll>
</et2-textbox>
<script>
    const field = document.getElementById("scroll-example");
    field.addEventListener("et2-scroll", (event) =>
    {
        field.value = String((parseInt(field.value) || 0) + event.detail);
    });
</script>

Stepping by something other than one

detail is a direction, not an amount, so a bigger step is a multiplication in your handler.

<et2-textbox id="scroll-step-example" value="100">
    <et2-button-scroll slot="suffix"></et2-button-scroll>
</et2-textbox>
<script>
    const stepField = document.getElementById("scroll-step-example");
    stepField.addEventListener("et2-scroll", (event) =>
    {
        stepField.value = String((parseInt(stepField.value) || 0) + 25 * event.detail);
    });
</script>

On mobile

The widget renders nothing at all on a mobile device. Two half-height targets stacked on top of each other are not something a thumb can hit, and a numeric keyboard is faster anyway - so whatever you slot it into has to remain usable without it.

Inherited properties (6)

ButtonMixin

Name Description
default_background_images images to be used as background-image, if none is explicitly applied and id matches given regular expression
default_classes Classnames added automatically to buttons to set certain hover background colors
hideOnReadonly If button is set to readonly, do we want to hide it completely (old behaviour) or show it as disabled (default) Something’s not quite right here, as the attribute shows up as “hideonreadonly” instead of “hide” but it does not show up without the “attribute”, and attribute:“hideonreadonly” does not show as an attribute
noSubmit Button should submit the etemplate Return false from the click handler to cancel the submit, or set noSubmit to true to skip submitting.
noValidation When submitting, skip the validation step. Allows to submit etemplates directly to the server.

LitElement

Name Description
updateComplete A read-only promise that resolves when the component has finished updating.

Events

Name Description Event Detail
et2-scroll Emitted when one of the buttons is clicked. Check event.detail for direction. 1 for up, -1 for down. example: Add the scroll into an input, then catch the et2-scroll event to adjust the value: handleScroll(e) { this.value = ”″ + (this.valueAsNumber + e.detail * (parseFloat(this.step) || 1)); } CustomEvent
click Missing description MouseEvent

Learn more about events.

Inherited methods (5)

ButtonMixin

Name Description
getInputNode() Reimplemented to pass aria-attributes to button
isDirty() Always return false as a button is never dirty
_get_default_class() Get a default class for the button based on ID
_get_default_image() Get a default image for the button based on ID
_register_default_keyhandler() If button ID has a default keyboard shortcut (eg: Save: Ctrl+S), register with egw_keymanager