From 5926a7649f76fc66b3a5ac81540d1d75c4f58be4 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko Date: Wed, 31 Aug 2022 22:17:46 +0300 Subject: [PATCH] Changed the type of the second argument of all Get functions to "subviewID ...string" (previously "subviewID string") --- CHANGELOG.md | 1 + README-ru.md | 306 +++++++++++++++++----------------- README.md | 306 +++++++++++++++++----------------- animation.go | 24 +-- animationEvents.go | 38 ++--- checkbox.go | 42 ++--- colorPicker.go | 24 +-- columnLayout.go | 46 +++--- datePicker.go | 46 +++--- detailsView.go | 18 +- dropDownList.go | 46 +++--- editView.go | 132 +++++++-------- filePicker.go | 31 ++-- focusEvents.go | 15 +- gridLayout.go | 40 ++--- imageView.go | 34 ++-- keyEvents.go | 18 +- listAdapter.go | 2 +- listLayout.go | 48 ++---- listView.go | 241 +++++++++------------------ mouseEvents.go | 34 ++-- numberPicker.go | 71 +++++--- pointerEvents.go | 26 +-- popup.go | 8 +- progressBar.go | 16 +- resizeEvent.go | 21 ++- scrollEvent.go | 37 +++-- tableView.go | 14 +- tableViewUtils.go | 112 ++++++------- tabsLayout.go | 4 +- textView.go | 6 +- timePicker.go | 46 +++--- touchEvents.go | 18 +- view.go | 28 ++-- viewClip.go | 16 +- viewFilter.go | 28 +++- viewTransform.go | 4 +- viewUtils.go | 399 +++++++++++++++++++++++---------------------- viewsContainer.go | 4 +- 39 files changed, 1138 insertions(+), 1212 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1912ce0..cccadc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Added GetListRowGap, GetListColumnGap, GetAccentColor, GetTabSize, GetOverflow, IsTimingFunctionValid, and GetTransitions functions * Changed GetTransition functions * Added the OpenURL function to the Session interface +* Changed the type of the second argument of all Get functions to "subviewID ...string" (previously "subviewID string") # v0.8.0 diff --git a/README-ru.md b/README-ru.md index 6b87ffb..2f00c07 100644 --- a/README-ru.md +++ b/README-ru.md @@ -538,17 +538,17 @@ SizeUnit или имя константы (о константах ниже): Это довольно громоздко поэтому для каждого свойства существует одноимённая глобальная функция с префиксом Get, которая выполняет данное приведение типа, получает значение константы, если необходимо, и -возвращает его. Все функции данного типа имеют два аргумента: View и subviewID string. -Первый аргумент это корневой View, второй - ID дочернего View. Если ID дочернего View передать как "", +возвращает его. Все функции данного типа имеют два аргумента: View и subviewID ...string. +Первый аргумент это корневой View, второй - ID дочернего View. Если ID дочернего View не задать или передать как "", то возвращается значение корневого View. Для свойств "width", "height", "min-width", "min-height", "max-width", "max-height" это функции: - func GetWidth(view View, subviewID string) SizeUnit - func GetHeight(view View, subviewID string) SizeUnit - func GetMinWidth(view View, subviewID string) SizeUnit - func GetMinHeight(view View, subviewID string) SizeUnit - func GetMaxWidth(view View, subviewID string) SizeUnit - func GetMaxHeight(view View, subviewID string) SizeUnit + func GetWidth(view View, subviewID ...string) SizeUnit + func GetHeight(view View, subviewID ...string) SizeUnit + func GetMinWidth(view View, subviewID ...string) SizeUnit + func GetMinHeight(view View, subviewID ...string) SizeUnit + func GetMaxWidth(view View, subviewID ...string) SizeUnit + func GetMaxHeight(view View, subviewID ...string) SizeUnit ### Свойство "resize" @@ -567,7 +567,7 @@ SizeUnit или имя константы (о константах ниже): Получить значение данного свойства можно с помощью функции - func GetResize(view View, subviewID string) int + func GetResize(view View, subviewID ...string) int ### Свойства "margin" и "padding" @@ -608,8 +608,8 @@ BoundsProperty с помощью функции "Bounds(session Session) Bounds" Для этого используется также могут использоваться глобальные функции: - func GetMargin(view View, subviewID string) Bounds - func GetPadding(view View, subviewID string) Bounds + func GetMargin(view View, subviewID ...string) Bounds + func GetPadding(view View, subviewID ...string) Bounds Текстовое представление BoundsProperty имеет следующий вид: @@ -743,7 +743,7 @@ BoundsProperty с помощью функции "Bounds(session Session) Bounds" BorderProperty, а не структура ViewBorders. Получить структуру ViewBorders без дополнительных преобразований можно с помощью глобальной функции - func GetBorder(view View, subviewID string) ViewBorders + func GetBorder(view View, subviewID ...string) ViewBorders Кроме вспомогательных свойств "style", "width" и "color" есть еще 4: "left", "right", "top" и "bottom". В качестве значения эти свойства могут принимать только структуру ViewBorder и позволяю установить все @@ -897,7 +897,7 @@ RadiusProperty имеет текстовое представление след RadiusProperty, а не структура BoxRadius. Получить структуру BoxRadius без дополнительных преобразований можно с помощью глобальной функции - func GetRadius(view View, subviewID string) BoxRadius + func GetRadius(view View, subviewID ...string) BoxRadius Вы также можете устанавливать отдельные радиусы использую функцию Set интерфейса View. Для этого используются следующие свойства @@ -973,7 +973,7 @@ RadiusProperty, а не структура BoxRadius. Получить стру Получить значение данного свойства можно с помощью функции - func GetViewShadows(view View, subviewID string) []ViewShadow + func GetViewShadows(view View, subviewID ...string) []ViewShadow Если тень не задана, то данная функция вернет пустой массив @@ -1234,7 +1234,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetOpacity(view View, subviewID string) float64 + func GetOpacity(view View, subviewID ...string) float64 ### Свойство "z-index" @@ -1244,7 +1244,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetZIndex(view View, subviewID string) int + func GetZIndex(view View, subviewID ...string) int ### Свойство "visibility" @@ -1258,7 +1258,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetVisibility(view View, subviewID string) int + func GetVisibility(view View, subviewID ...string) int ### Свойства "filter" и "backdrop-filter" @@ -1287,8 +1287,8 @@ radius необходимо передать nil Получить значение текущего фильтра можно с помощью функций - func GetFilter(view View, subviewID string) ViewFilter - func GetBackdropFilter(view View, subviewID string) ViewFilter + func GetFilter(view View, subviewID ...string) ViewFilter + func GetBackdropFilter(view View, subviewID ...string) ViewFilter ### Свойство "semantics" @@ -1335,7 +1335,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetFontName(view View, subviewID string) string + func GetFontName(view View, subviewID ...string) string #### Свойство "text-color" @@ -1343,7 +1343,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextColor(view View, subviewID string) Color + func GetTextColor(view View, subviewID ...string) Color #### Свойство "text-size" @@ -1351,7 +1351,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextSize(view View, subviewID string) SizeUnit + func GetTextSize(view View, subviewID ...string) SizeUnit #### Свойство "italic" @@ -1359,7 +1359,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func IsItalic(view View, subviewID string) bool + func IsItalic(view View, subviewID ...string) bool #### Свойство "small-caps" @@ -1367,7 +1367,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func IsSmallCaps(view View, subviewID string) bool + func IsSmallCaps(view View, subviewID ...string) bool #### Свойство "white-space" @@ -1442,9 +1442,9 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функций - func IsStrikethrough(view View, subviewID string) bool - func IsOverline(view View, subviewID string) bool - func IsUnderline(view View, subviewID string) bool + func IsStrikethrough(view View, subviewID ...string) bool + func IsOverline(view View, subviewID ...string) bool + func IsUnderline(view View, subviewID ...string) bool #### Свойство "text-line-thickness" @@ -1453,7 +1453,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - GetTextLineThickness(view View, subviewID string) SizeUnit + GetTextLineThickness(view View, subviewID ...string) SizeUnit #### Свойство "text-line-style" @@ -1473,7 +1473,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextLineStyle(view View, subviewID string) int + func GetTextLineStyle(view View, subviewID ...string) int #### Свойство "text-line-color" @@ -1483,7 +1483,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextLineColor(view View, subviewID string) Color + func GetTextLineColor(view View, subviewID ...string) Color #### Свойство "text-weight" @@ -1505,7 +1505,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextWeight(view View, subviewID string) int + func GetTextWeight(view View, subviewID ...string) int #### Свойство "text-shadow" @@ -1532,7 +1532,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextShadows(view View, subviewID string) []ViewShadow + func GetTextShadows(view View, subviewID ...string) []ViewShadow Если тень не задана, то данная функция вернет пустой массив @@ -1549,7 +1549,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextAlign(view View, subviewID string) int + func GetTextAlign(view View, subviewID ...string) int #### Свойство "text-indent" @@ -1557,7 +1557,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextIndent(view View, subviewID string) SizeUnit + func GetTextIndent(view View, subviewID ...string) SizeUnit #### Свойство "letter-spacing" @@ -1567,7 +1567,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetLetterSpacing(view View, subviewID string) SizeUnit + func GetLetterSpacing(view View, subviewID ...string) SizeUnit #### Свойство "word-spacing" @@ -1577,7 +1577,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetWordSpacing(view View, subviewID string) SizeUnit + func GetWordSpacing(view View, subviewID ...string) SizeUnit #### Свойство "line-height" @@ -1585,7 +1585,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetLineHeight(view View, subviewID string) SizeUnit + func GetLineHeight(view View, subviewID ...string) SizeUnit #### Свойство "text-transform" @@ -1600,7 +1600,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextTransform(view View, subviewID string) int + func GetTextTransform(view View, subviewID ...string) int #### Свойство "text-direction" @@ -1614,7 +1614,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetTextDirection(view View, subviewID string) int + func GetTextDirection(view View, subviewID ...string) int #### Свойство "writing-mode" @@ -1631,7 +1631,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetWritingMode(view View, subviewID string) int + func GetWritingMode(view View, subviewID ...string) int #### Свойство "vertical-text-orientation" @@ -1646,7 +1646,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetVerticalTextOrientation(view View, subviewID string) int + func GetVerticalTextOrientation(view View, subviewID ...string) int #### Свойство "user-select" @@ -1662,7 +1662,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func IsUserSelect(view View, subviewID string) bool + func IsUserSelect(view View, subviewID ...string) bool ### Свойства трансформации @@ -1681,7 +1681,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetPerspective(view View, subviewID string) SizeUnit + func GetPerspective(view View, subviewID ...string) SizeUnit #### Свойства "perspective-origin-x" и "perspective-origin-y" @@ -1692,7 +1692,7 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функции - func GetPerspectiveOrigin(view View, subviewID string) (SizeUnit, SizeUnit) + func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) #### Свойство "backface-visibility" @@ -1705,7 +1705,7 @@ radius необходимо передать nil Получить значение данного свойства можно с помощью функции - func GetBackfaceVisible(view View, subviewID string) bool + func GetBackfaceVisible(view View, subviewID ...string) bool #### Свойства "origin-x", "origin-y" и "origin-z" @@ -1718,7 +1718,7 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функции - func GetOrigin(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) + func GetOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) #### Свойства "translate-x", "translate-y" и "translate-z" @@ -1729,7 +1729,7 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функции - func GetTranslate(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) + func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) #### Свойства "scale-x", "scale-y" и "scale-z" @@ -1742,7 +1742,7 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функции - func GetScale(view View, subviewID string) (float64, float64, float64) + func GetScale(view View, subviewID ...string) (float64, float64, float64) #### Свойства "rotate" @@ -1759,7 +1759,7 @@ radius необходимо передать nil Получить значение данных свойств, а также свойства "rotate" можно с помощью функции - func GetRotate(view View, subviewID string) (float64, float64, float64, AngleUnit) + func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) #### Свойства "skew-x" и "skew-y" @@ -1769,7 +1769,7 @@ radius необходимо передать nil Получить значение данных свойств можно с помощью функции - func GetSkew(view View, subviewID string) (AngleUnit, AngleUnit) + func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) ### Пользовательские данные @@ -1809,8 +1809,8 @@ radius необходимо передать nil Получить списки слушателей событий клавиатуры можно с помощью функций: - func GetKeyDownListeners(view View, subviewID string) []func(View, KeyEvent) - func GetKeyUpListeners(view View, subviewID string) []func(View, KeyEvent) + func GetKeyDownListeners(view View, subviewID ...string) []func(View, KeyEvent) + func GetKeyUpListeners(view View, subviewID ...string) []func(View, KeyEvent) ### События фокуса @@ -1831,8 +1831,8 @@ radius необходимо передать nil Получить списки слушателей событий фокуса можно с помощью функций: - func GetFocusListeners(view View, subviewID string) []func(View) - func GetLostFocusListeners(view View, subviewID string) []func(View) + func GetFocusListeners(view View, subviewID ...string) []func(View) + func GetLostFocusListeners(view View, subviewID ...string) []func(View) ### События мыши @@ -1900,14 +1900,14 @@ radius необходимо передать nil Получить списки слушателей событий мыши можно с помощью функций: - func GetMouseDownListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseUpListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseMoveListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseOverListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseOutListeners(view View, subviewID string) []func(View, MouseEvent) - func GetClickListeners(view View, subviewID string) []func(View, MouseEvent) - func GetDoubleClickListeners(view View, subviewID string) []func(View, MouseEvent) - func GetContextMenuListeners(view View, subviewID string) []func(View, MouseEvent) + func GetMouseDownListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseUpListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseMoveListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseOverListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseOutListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetClickListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetDoubleClickListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetContextMenuListeners(view View, subviewID ...string) []func(View, MouseEvent) ### События указателя @@ -1954,12 +1954,12 @@ radius необходимо передать nil Получить списки слушателей событий указателя можно с помощью функций: - func GetPointerDownListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerUpListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerMoveListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerCancelListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerOverListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerOutListeners(view View, subviewID string) []func(View, PointerEvent) + func GetPointerDownListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerUpListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerMoveListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerCancelListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerOverListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerOutListeners(view View, subviewID ...string) []func(View, PointerEvent) ### Touch события @@ -2012,10 +2012,10 @@ radius необходимо передать nil Получить списки слушателей событий касания можно с помощью функций: - func GetTouchStartListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchEndListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchMoveListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchCancelListeners(view View, subviewID string) []func(View, TouchEvent) + func GetTouchStartListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchEndListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchMoveListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchCancelListeners(view View, subviewID ...string) []func(View, TouchEvent) ### Событие "resize-event" @@ -2044,7 +2044,7 @@ radius необходимо передать nil Получить список слушателей данного события можно с помощью функции: - func GetResizeListeners(view View, subviewID string) []func(View, Frame) + func GetResizeListeners(view View, subviewID ...string) []func(View, Frame) Текущие положение и размеры видимой части View можно получить с помощью функции интерфейса View: @@ -2052,7 +2052,7 @@ radius необходимо передать nil или глобальной функции - func GetViewFrame(view View, subviewID string) Frame + func GetViewFrame(view View, subviewID ...string) Frame ### Событие прокрутки @@ -2083,13 +2083,13 @@ radius необходимо передать nil или глобальной функции - func GetViewScroll(view View, subviewID string) Frame + func GetViewScroll(view View, subviewID ...string) Frame Для программной прокрутки могут использоваться следующие глобальные функции func ScrollViewTo(view View, subviewID string, x, y float64) - func ScrollViewToStart(view View, subviewID string) - func ScrollViewToEnd(view View, subviewID string) + func ScrollViewToStart(view View, subviewID ...string) + func ScrollViewToEnd(view View, subviewID ...string) которые прокручивают view, соответственно, в заданную позицию, начало и конец @@ -2363,7 +2363,7 @@ ColumnLayout является контейнером, реализующим и Получить значение данного свойства можно с помощью функции - func GetColumnCount(view View, subviewID string) int + func GetColumnCount(view View, subviewID ...string) int ### Свойство "column-width" @@ -2375,7 +2375,7 @@ ColumnLayout является контейнером, реализующим и Получить значение данного свойства можно с помощью функции - func GetColumnWidth(view View, subviewID string) SizeUnit + func GetColumnWidth(view View, subviewID ...string) SizeUnit ### Свойство "column-gap" @@ -2383,7 +2383,7 @@ ColumnLayout является контейнером, реализующим и Получить значение данного свойства можно с помощью функции - func GetColumnGap(view View, subviewID string) SizeUnit + func GetColumnGap(view View, subviewID ...string) SizeUnit ### Свойство "column-separator" @@ -2431,7 +2431,7 @@ ViewBorder описана как а не структура ViewBorder. Получить структуру ViewBorders без дополнительных преобразований можно с помощью глобальной функции - func GetColumnSeparator(view View, subviewID string) ViewBorder + func GetColumnSeparator(view View, subviewID ...string) ViewBorder Вы также можете устанавливать отдельные атрибуты линии использую функцию Set интерфейса View. Для этого используются следующие свойства @@ -2469,7 +2469,7 @@ ViewBorder описана как Получить значение данного свойства можно с помощью функции - func GetAvoidBreak(view View, subviewID string) bool + func GetAvoidBreak(view View, subviewID ...string) bool ## StackLayout @@ -2515,7 +2515,7 @@ StackLayout является контейнером, реализующим ин func peek(layout rui.StackLayout) { views := layout.Views() - if index := rui.GetCurrent(layout, ""); index >= 0 && index < len(views) { + if index := rui.GetCurrent(layout); index >= 0 && index < len(views) { return views[index] } return nil @@ -2584,7 +2584,7 @@ Cвойства "tab-close-button" может быть задано как дл Для программного переключания вкладок присвойте данному свойству значение индекса новой текущего View. Прочитать значение свойства "current" можно с помощью функции - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int Также свойство "current" может быть использовано для отслеживания изменения текущего View: @@ -2660,11 +2660,11 @@ View, "false" - скрывает. Получить значение свойства "expanded" можно с помощью функции - func IsDetailsExpanded(view View, subviewID string) bool + func IsDetailsExpanded(view View, subviewID ...string) bool а значение свойства "summary" можно получить с помощью функции - func GetDetailsSummary(view View, subviewID string) View + func GetDetailsSummary(view View, subviewID ...string) View ## Resizable @@ -2708,7 +2708,7 @@ AllSides определено как Выводимый текст задается string свойством "text" (константа Text). Помимо метода Get значение свойства "text" может быть получено с помощью функции - func GetText(view View, subviewID string) string + func GetText(view View, subviewID ...string) string TextView наследует от View все свойства параметров текста ("font-name", "text-size", "text-color" и т.д.). Кроме них добавляется еще один "text-overflow" (константа TextOverflow). Он определяет как обрезается @@ -2791,11 +2791,11 @@ NaturalSize() возвращает исходную ширину и высоту Для получения значений свойств ImageView могут использоваться следующие функции: - func GetImageViewSource(view View, subviewID string) string - func GetImageViewAltText(view View, subviewID string) string - func GetImageViewFit(view View, subviewID string) int - func GetImageViewVerticalAlign(view View, subviewID string) int - func GetImageViewHorizontalAlign(view View, subviewID string) int + func GetImageViewSource(view View, subviewID ...string) string + func GetImageViewAltText(view View, subviewID ...string) string + func GetImageViewFit(view View, subviewID ...string) int + func GetImageViewVerticalAlign(view View, subviewID ...string) int + func GetImageViewHorizontalAlign(view View, subviewID ...string) int ## EditView @@ -2851,15 +2851,15 @@ Cвойство "caret-color" может быть задано не только Для получения значений свойств EditView могут использоваться следующие функции: - func GetText(view View, subviewID string) string - func GetHint(view View, subviewID string) string - func GetMaxLength(view View, subviewID string) int - func GetEditViewType(view View, subviewID string) int - func GetEditViewPattern(view View, subviewID string) string - func IsReadOnly(view View, subviewID string) bool - func IsEditViewWrap(view View, subviewID string) bool - func IsSpellcheck(view View, subviewID string) bool - func GetCaretColor(view View, subviewID string) Color + func GetText(view View, subviewID ...string) string + func GetHint(view View, subviewID ...string) string + func GetMaxLength(view View, subviewID ...string) int + func GetEditViewType(view View, subviewID ...string) int + func GetEditViewPattern(view View, subviewID ...string) string + func IsReadOnly(view View, subviewID ...string) bool + func IsEditViewWrap(view View, subviewID ...string) bool + func IsSpellcheck(view View, subviewID ...string) bool + func GetCaretColor(view View, subviewID ...string) Color Для отслеживания изменения текста используется событие "edit-text-changed" (константа EditTextChangedEvent). Основной слушатель события имеет следующий формат: @@ -2870,7 +2870,7 @@ EditTextChangedEvent). Основной слушатель события име Получить текущий список слушателей изменения текста можно с помощью функции - func GetTextChangedListeners(view View, subviewID string) []func(EditView, string) + func GetTextChangedListeners(view View, subviewID ...string) []func(EditView, string) ## NumberPicker @@ -2903,7 +2903,7 @@ NumberPicker может работать в двух режимах: редак Все эти типы приводятся к float64. Соответственно функция Get всегда возвращает float64 значение. Прочитано значение свойства "number-picker-value" может быть также с помощью функции: - func GetNumberPickerValue(view View, subviewID string) float64 + func GetNumberPickerValue(view View, subviewID ...string) float64 На вводимые значения могут быть наложены ограничения. Для этого используются следующие свойства: @@ -2921,8 +2921,8 @@ NumberPicker может работать в двух режимах: редак Прочитать значения данных свойств можно с помощью функций: - func GetNumberPickerMinMax(view View, subviewID string) (float64, float64) - func GetNumberPickerStep(view View, subviewID string) float64 + func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) + func GetNumberPickerStep(view View, subviewID ...string) float64 Для отслеживания изменения вводимого значения используется событие "number-changed" (константа NumberChangedEvent). Основной слушатель события имеет следующий формат: @@ -2933,7 +2933,7 @@ NumberChangedEvent). Основной слушатель события име Получить текущий список слушателей изменения значения можно с помощью функции - func GetNumberChangedListeners(view View, subviewID string) []func(NumberPicker, float64) + func GetNumberChangedListeners(view View, subviewID ...string) []func(NumberPicker, float64) ## DatePicker @@ -2954,7 +2954,7 @@ NumberChangedEvent). Основной слушатель события име Текст преобразуется в time.Time. Соответственно функция Get всегда возвращает time.Time значение. Прочитано значение свойства "date-picker-value" может быть также с помощью функции: - func GetDatePickerValue(view View, subviewID string) time.Time + func GetDatePickerValue(view View, subviewID ...string) time.Time На вводимые даты могут быть наложены ограничения. Для этого используются следующие свойства: @@ -2966,9 +2966,9 @@ NumberChangedEvent). Основной слушатель события име Прочитать значения данных свойств можно с помощью функций: - func GetDatePickerMin(view View, subviewID string) (time.Time, bool) - func GetDatePickerMax(view View, subviewID string) (time.Time, bool) - func GetDatePickerStep(view View, subviewID string) int + func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) + func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) + func GetDatePickerStep(view View, subviewID ...string) int Для отслеживания изменения вводимого значения используется событие "date-changed" (константа DateChangedEvent). Основной слушатель события имеет следующий формат: @@ -2979,7 +2979,7 @@ DateChangedEvent). Основной слушатель события имее Получить текущий список слушателей изменения даты можно с помощью функции - func GetDateChangedListeners(view View, subviewID string) []func(DatePicker, time.Time) + func GetDateChangedListeners(view View, subviewID ...string) []func(DatePicker, time.Time) ## TimePicker @@ -3000,7 +3000,7 @@ DateChangedEvent). Основной слушатель события имее Текст преобразуется в time.Time. Соответственно функция Get всегда возвращает time.Time значение. Прочитано значение свойства "time-picker-value" может быть также с помощью функции: - func GetTimePickerValue(view View, subviewID string) time.Time + func GetTimePickerValue(view View, subviewID ...string) time.Time На вводимое время могут быть наложены ограничения. Для этого используются следующие свойства: @@ -3012,9 +3012,9 @@ DateChangedEvent). Основной слушатель события имее Прочитать значения данных свойств можно с помощью функций: - func GetTimePickerMin(view View, subviewID string) (time.Time, bool) - func GetTimePickerMax(view View, subviewID string) (time.Time, bool) - func GetTimePickerStep(view View, subviewID string) int + func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) + func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) + func GetTimePickerStep(view View, subviewID ...string) int Для отслеживания изменения вводимого значения используется событие "time-changed" (константа TimeChangedEvent). Основной слушатель события имеет следующий формат: @@ -3025,7 +3025,7 @@ TimeChangedEvent). Основной слушатель события имее Получить текущий список слушателей изменения даты можно с помощью функции - func GetTimeChangedListeners(view View, subviewID string) []func(TimePicker, time.Time) + func GetTimeChangedListeners(view View, subviewID ...string) []func(TimePicker, time.Time) ## ColorPicker @@ -3044,7 +3044,7 @@ TimeChangedEvent). Основной слушатель события имее Прочитано значение свойства "color-picker-value" может быть также с помощью функции: - func GetColorPickerValue(view View, subviewID string) Color + func GetColorPickerValue(view View, subviewID ...string) Color Для отслеживания изменения выбранного цвета используется событие "color-changed" (константа ColorChangedEvent). Основной слушатель события имеет следующий формат: @@ -3055,7 +3055,7 @@ ColorChangedEvent). Основной слушатель события имее Получить текущий список слушателей изменения даты можно с помощью функции - func GetColorChangedListeners(view View, subviewID string) []func(ColorPicker, Color) + func GetColorChangedListeners(view View, subviewID ...string) []func(ColorPicker, Color) ## FilePicker @@ -3084,7 +3084,7 @@ ColorChangedEvent). Основной слушатель события имее а также соответствующие им глобальные функции - func GetFilePickerFiles(view View, subviewID string) []FileInfo + func GetFilePickerFiles(view View, subviewID ...string) []FileInfo func LoadFilePickerFile(view View, subviewID string, file FileInfo, result func(FileInfo, []byte)) Функции Files/GetFilePickerFiles возвращают список выбранных файлов в виде среза структур FileInfo. Структура FileInfo объявлена как @@ -3136,7 +3136,7 @@ FileInfo содержит только информацию о файле, но Получить текущий список слушателей изменения списка файлов можно с помощью функции - func GetFileSelectedListeners(view View, subviewID string) []func(FilePicker, []FileInfo) + func GetFileSelectedListeners(view View, subviewID ...string) []func(FilePicker, []FileInfo) ## DropDownList @@ -3157,7 +3157,7 @@ float32, float64, int, int8…int64, uint, uint8…uint64. Все эти типы данных преопразуются в []string и присваиваются свойству "items". Прочитать значение свойства "items" можно с помощью функции - func GetDropDownItems(view View, subviewID string) []string + func GetDropDownItems(view View, subviewID ...string) []string Можно запретить выбор отдельных пунктов. Для этого используется свойство "disabled-items" (константа DisabledItems). Данному свойству присваивается массив индексов запрещенных пунктов. Индекс может задаваться или числом или в виде текста @@ -3172,12 +3172,12 @@ float32, float64, int, int8…int64, uint, uint8…uint64. Все эти типы данных преопразуются в []any и присваиваются свойству "disabled-items". Прочитать значение свойства "disabled-items" можно с помощью функции - func GetDropDownDisabledItems(view View, subviewID string) []int + func GetDropDownDisabledItems(view View, subviewID ...string) []int Выбранное значение определяется int свойством "current" (константа Current). Значение по умолчанию 0. Прочитать значение данного свойства можно с помощью функции - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int Для отслеживания изменения свойства "current" используется событие "drop-down-event" (константа DropDownEvent). Основной слушатель события имеет следующий формат: @@ -3188,7 +3188,7 @@ DropDownEvent). Основной слушатель события имеет с Получить текущий список слушателей изменения даты можно с помощью функции - func GetDropDownListeners(view View, subviewID string) []func(DropDownList, int) + func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, int) ## ProgressBar @@ -3209,8 +3209,8 @@ int8…int64, uint, uint8…uint64 Прочитать значение данных свойств можно с помощью функций - func GetProgressBarMax(view View, subviewID string) float64 - func GetProgressBarValue(view View, subviewID string) float64 + func GetProgressBarMax(view View, subviewID ...string) float64 + func GetProgressBarValue(view View, subviewID ...string) float64 ## Button @@ -3269,7 +3269,7 @@ View и string преобразуется в string, далее все string в с помощью функции NewViewListAdapter получается ListAdapter. Если элементы списка меняются в ходе работы, то после изменения необходимо вызывать или функцию -ReloadListViewData() интерфейса ListView или глобальную функцию ReloadListViewData(view View, subviewID string). +ReloadListViewData() интерфейса ListView или глобальную функцию ReloadListViewData(view View, subviewID ...string). Данные функции обновляют отображаемые элементы списка. ### Свойство "orientation" @@ -3291,7 +3291,7 @@ ReloadListViewData() интерфейса ListView или глобальную Получить значение данного свойства можно с помощью функции - func GetListOrientation(view View, subviewID string) int + func GetListOrientation(view View, subviewID ...string) int ### Свойство "wrap" @@ -3308,7 +3308,7 @@ ReloadListViewData() интерфейса ListView или глобальную Получить значение данного свойства можно с помощью функции - func GetListWrap(view View, subviewID string) int + func GetListWrap(view View, subviewID ...string) int ### Свойства "item-width" и "item-height" @@ -3321,8 +3321,8 @@ ReloadListViewData() интерфейса ListView или глобальную Получить значения данных свойств можно с помощью функций - func GetListItemWidth(view View, subviewID string) SizeUnit - func GetListItemHeight(view View, subviewID string) SizeUnit + func GetListItemWidth(view View, subviewID ...string) SizeUnit + func GetListItemHeight(view View, subviewID ...string) SizeUnit ### Свойство "item-vertical-align" @@ -3338,7 +3338,7 @@ ReloadListViewData() интерфейса ListView или глобальную Получить значение данного свойства можно с помощью функции - func GetListItemVerticalAlign(view View, subviewID string) int + func GetListItemVerticalAlign(view View, subviewID ...string) int ### Свойство "item-horizontal-align" @@ -3354,7 +3354,7 @@ ReloadListViewData() интерфейса ListView или глобальную Получить значение данного свойства можно с помощью функции - GetListItemHorizontalAlign(view View, subviewID string) int + GetListItemHorizontalAlign(view View, subviewID ...string) int ### Свойство "current" @@ -3365,7 +3365,7 @@ int свойство "current" (константа Current). Значение "c Получить значение данного свойства можно с помощью функции - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int ### Свойства "list-item-style", "current-style" и "current-inactive-style" @@ -3393,13 +3393,13 @@ int свойство "current" (константа Current). Значение "c Получить значение данного свойства можно с помощью функции - func GetListViewCheckbox(view View, subviewID string) int + func GetListViewCheckbox(view View, subviewID ...string) int Получить/установить список помеченных пунктов можно с помощью свойства "checked" (константа Checked). Данное свойство имеет тип []int и хранит индексы помеченных элементов. Получить значение данного свойства можно с помощью функции - func GetListViewCheckedItems(view View, subviewID string) []int + func GetListViewCheckedItems(view View, subviewID ...string) []int Проверить помечен ли конкретный элемент можно с помощью функции @@ -3430,8 +3430,8 @@ CheckboxHorizontalAlign и CheckboxVerticalAlign) Получить значения свойств можно "checkbox-horizontal-align" и "checkbox-vertical-align" с помощью функций - func GetListViewCheckboxHorizontalAlign(view View, subviewID string) int - func GetListViewCheckboxVerticalAlign(view View, subviewID string) int + func GetListViewCheckboxHorizontalAlign(view View, subviewID ...string) int + func GetListViewCheckboxVerticalAlign(view View, subviewID ...string) int ### События ListView @@ -3451,9 +3451,9 @@ CheckboxHorizontalAlign и CheckboxVerticalAlign) Получить списки слушателей данных событий можно с помощью функций: - func GetListItemClickedListeners(view View, subviewID string) []func(ListView, int) - func GetListItemSelectedListeners(view View, subviewID string) []func(ListView, int) - func GetListItemCheckedListeners(view View, subviewID string) []func(ListView, []int) + func GetListItemClickedListeners(view View, subviewID ...string) []func(ListView, int) + func GetListItemSelectedListeners(view View, subviewID ...string) []func(ListView, int) + func GetListItemCheckedListeners(view View, subviewID ...string) []func(ListView, []int) ## TableView @@ -3650,7 +3650,7 @@ TableColumnStyle объявлена как Получить значение данного свойства можно с помощью функции - func GetTableVerticalAlign(view View, subviewID string) int + func GetTableVerticalAlign(view View, subviewID ...string) int ### Свойство "selection-mode" @@ -3672,7 +3672,7 @@ TableColumnStyle объявлена как Получить значение данного свойства можно с помощью функции - func GetSelectionMode(view View, subviewID string) int + func GetSelectionMode(view View, subviewID ...string) int ### Свойство "current" @@ -3690,7 +3690,7 @@ TableColumnStyle объявлена как Получить значение данного свойства можно с помощью функции - func GetTableCurrent(view View, subviewID string) CellIndex + func GetTableCurrent(view View, subviewID ...string) CellIndex ### Свойство "allow-selection" @@ -4638,7 +4638,7 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Для получения текущего списка постоянных анимаций перехода используется функция - func GetTransition(view View, subviewID string) Params + func GetTransition(view View, subviewID ...string) Params Добавлять новые анимации перехода рекомендуется с помощью функции @@ -4675,10 +4675,10 @@ x1 и x2 должны быть в диапазоне [0, 1]. Вы можете Получить списки слушателей событий анимации перехода с помощью функций: - func GetTransitionRunListeners(view View, subviewID string) []func(View, string) - func GetTransitionStartListeners(view View, subviewID string) []func(View, string) - func GetTransitionEndListeners(view View, subviewID string) []func(View, string) - func GetTransitionCancelListeners(view View, subviewID string) []func(View, string) + func GetTransitionRunListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionStartListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionEndListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionCancelListeners(view View, subviewID ...string) []func(View, string) ### Cценарий анимации @@ -4807,10 +4807,10 @@ Safari и Firefox. Получить списки слушателей событий анимации с помощью функций: - func GetAnimationStartListeners(view View, subviewID string) []func(View, string) - func GetAnimationEndListeners(view View, subviewID string) []func(View, string) - func GetAnimationCancelListeners(view View, subviewID string) []func(View, string) - func GetAnimationIterationListeners(view View, subviewID string) []func(View, string) + func GetAnimationStartListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationEndListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationCancelListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationIterationListeners(view View, subviewID ...string) []func(View, string) ## Сессия diff --git a/README.md b/README.md index caa8057..5fadc61 100644 --- a/README.md +++ b/README.md @@ -540,17 +540,17 @@ After getting the value with the Get function, you must typecast: This is quite cumbersome, therefore for each property there is a global function of the same name with the Get prefix, which performs the given cast, gets the value of the constant, if necessary, and returns it. -All functions of this type have two arguments: View and subviewID string. +All functions of this type have two arguments: View and subviewID ...string. The first argument is the root View, the second is the ID of the child View. -If the ID of the child View is passed as "", then the value of the root View is returned. +If the ID of the child View is not specified or is passed as "", then the value of the root View is returned. For the properties "width", "height", "min-width", "min-height", "max-width", "max-height" these are functions: - func GetWidth(view View, subviewID string) SizeUnit - func GetHeight(view View, subviewID string) SizeUnit - func GetMinWidth(view View, subviewID string) SizeUnit - func GetMinHeight(view View, subviewID string) SizeUnit - func GetMaxWidth(view View, subviewID string) SizeUnit - func GetMaxHeight(view View, subviewID string) SizeUnit + func GetWidth(view View, subviewID ...string) SizeUnit + func GetHeight(view View, subviewID ...string) SizeUnit + func GetMinWidth(view View, subviewID ...string) SizeUnit + func GetMinHeight(view View, subviewID ...string) SizeUnit + func GetMaxWidth(view View, subviewID ...string) SizeUnit + func GetMaxHeight(view View, subviewID ...string) SizeUnit ### "resize" property @@ -569,7 +569,7 @@ The default value for a multiline text editor is BothResize(1). You can get the value of this property using the function - func GetResize(view View, subviewID string) int + func GetResize(view View, subviewID ...string) int ### "margin" and "padding" properties @@ -609,8 +609,8 @@ can be converted to a more convenient Bounds structure: Global functions can also be used for this: - func GetMargin(view View, subviewID string) Bounds - func GetPadding(view View, subviewID string) Bounds + func GetMargin(view View, subviewID ...string) Bounds + func GetPadding(view View, subviewID ...string) Bounds The textual representation of the BoundsProperty is as follows: @@ -744,7 +744,7 @@ This converts the ViewBorders to BorderProperty. Therefore, when the property is the Get function will return the BorderProperty interface, not the ViewBorders structure. You can get the ViewBorders structure without additional transformations using the global function - func GetBorder(view View, subviewID string) ViewBorders + func GetBorder(view View, subviewID ...string) ViewBorders Besides the auxiliary properties "style", "width" and "color" there are 4 more: "left", "right", "top" and "bottom". As a value, these properties can only take the ViewBorder structure and allow you to set all the attributes of the line of the side of the same name. @@ -880,7 +880,7 @@ This converts BoxRadius to RadiusProperty. Therefore, when the property is read, the Get function will return the RadiusProperty interface, not the BoxRadius structure. You can get the BoxRadius structure without additional transformations using the global function - func GetRadius(view View, subviewID string) BoxRadius + func GetRadius(view View, subviewID ...string) BoxRadius You can also set individual radii using the Set function of the View interface. For this, the following properties are used @@ -955,7 +955,7 @@ The ViewShadow text representation has the following format: You can get the value of "shadow" property using the function - func GetViewShadows(view View, subviewID string) []ViewShadow + func GetViewShadows(view View, subviewID ...string) []ViewShadow If no shadow is specified, then this function will return an empty array @@ -1214,7 +1214,7 @@ Where 1 - View is fully opaque, 0 - fully transparent. You can get the value of this property using the function - func GetOpacity(view View, subviewID string) float64 + func GetOpacity(view View, subviewID ...string) float64 ### "z-index" property @@ -1224,7 +1224,7 @@ higher z-indexes overlap elements with lower. You can get the value of this property using the function - func GetZIndex(view View, subviewID string) int + func GetZIndex(view View, subviewID ...string) int ### "visibility" property @@ -1238,7 +1238,7 @@ The "visibility" int property (constant Visibility) specifies the visibility of You can get the value of this property using the function - func GetVisibility(view View, subviewID string) int + func GetVisibility(view View, subviewID ...string) int ### "filter" and "backdrop-filter" properties @@ -1274,8 +1274,8 @@ Example You can get the value of the current filter using functions - func GetFilter(view View, subviewID string) ViewFilter - func GetBackdropFilter(view View, subviewID string) ViewFilter + func GetFilter(view View, subviewID ...string) ViewFilter + func GetBackdropFilter(view View, subviewID ...string) ViewFilter ### "semantics" property @@ -1322,7 +1322,7 @@ if it is not available, then the second, third, etc. You can get the value of this property using the function - func GetFontName(view View, subviewID string) string + func GetFontName(view View, subviewID ...string) string #### "text-color" property @@ -1330,7 +1330,7 @@ Property "text-color" (constant TextColor) - the Color property determines the c You can get the value of this property using the function - func GetTextColor(view View, subviewID string) Color + func GetTextColor(view View, subviewID ...string) Color #### "text-size" property @@ -1338,7 +1338,7 @@ Property "text-size" (constant TextSize) - the SizeUnit property determines the You can get the value of this property using the function - func GetTextSize(view View, subviewID string) SizeUnit + func GetTextSize(view View, subviewID ...string) SizeUnit #### "italic" property @@ -1346,7 +1346,7 @@ The "italic" property (constant Italic) is the bool property. If the value is tr You can get the value of this property using the function - func IsItalic(view View, subviewID string) bool + func IsItalic(view View, subviewID ...string) bool #### "small-caps" property @@ -1354,7 +1354,7 @@ The "small-caps" property (SmallCaps constant) is the bool property. If the valu You can get the value of this property using the function - func IsSmallCaps(view View, subviewID string) bool + func IsSmallCaps(view View, subviewID ...string) bool #### "white-space" property @@ -1426,9 +1426,9 @@ These bool properties set decorative lines on the text: You can get the value of these properties using the functions - func IsStrikethrough(view View, subviewID string) bool - func IsOverline(view View, subviewID string) bool - func IsUnderline(view View, subviewID string) bool + func IsStrikethrough(view View, subviewID ...string) bool + func IsOverline(view View, subviewID ...string) bool + func IsUnderline(view View, subviewID ...string) bool #### "text-line-thickness" property @@ -1437,7 +1437,7 @@ of decorative lines on the text set using the "strikethrough", "overline" and "u You can get the value of this property using the function - GetTextLineThickness(view View, subviewID string) SizeUnit + GetTextLineThickness(view View, subviewID ...string) SizeUnit #### "text-line-style" property @@ -1456,7 +1456,7 @@ Possible values are: You can get the value of this property using the function - func GetTextLineStyle(view View, subviewID string) int + func GetTextLineStyle(view View, subviewID ...string) int #### "text-line-color" property @@ -1466,7 +1466,7 @@ If the property is not defined, then the text color specified by the "text-color You can get the value of this property using the function - func GetTextLineColor(view View, subviewID string) Color + func GetTextLineColor(view View, subviewID ...string) Color #### "text-weight" property @@ -1488,7 +1488,7 @@ Some fonts are only available in normal or bold style. In this case, the value o You can get the value of this property using the function - func GetTextWeight(view View, subviewID string) int + func GetTextWeight(view View, subviewID ...string) int #### "text-shadow" property @@ -1513,7 +1513,7 @@ ViewShadow, ViewShadow array, ViewShadow textual representation can be assigned You can get the value of this property using the function - func GetTextShadows(view View, subviewID string) []ViewShadow + func GetTextShadows(view View, subviewID ...string) []ViewShadow If no shadow is specified, then this function will return an empty array @@ -1530,7 +1530,7 @@ The "text-align" int property (constant TextAlign) sets the alignment of the tex You can get the value of this property using the function - func GetTextAlign(view View, subviewID string) int + func GetTextAlign(view View, subviewID ...string) int #### "text-indent" property @@ -1539,7 +1539,7 @@ before the first line of text. You can get the value of this property using the function - func GetTextIndent(view View, subviewID string) SizeUnit + func GetTextIndent(view View, subviewID ...string) SizeUnit #### "letter-spacing" property @@ -1549,7 +1549,7 @@ The user agent can choose not to increase or decrease the letter spacing to alig You can get the value of this property using the function - func GetLetterSpacing(view View, subviewID string) SizeUnit + func GetLetterSpacing(view View, subviewID ...string) SizeUnit #### "word-spacing" property @@ -1559,7 +1559,7 @@ Otherwise, it specifies additional spacing in addition to the inner word spacing You can get the value of this property using the function - func GetWordSpacing(view View, subviewID string) SizeUnit + func GetWordSpacing(view View, subviewID ...string) SizeUnit #### "line-height" property @@ -1567,7 +1567,7 @@ The "line-height" (LineHeight constant) SizeUnit property sets the amount of spa You can get the value of this property using the function - func GetLineHeight(view View, subviewID string) SizeUnit + func GetLineHeight(view View, subviewID ...string) SizeUnit #### "text-transform" property @@ -1582,7 +1582,7 @@ The "text-transform" (TextTransform constant) int property defines the case of c You can get the value of this property using the function - func GetTextTransform(view View, subviewID string) int + func GetTextTransform(view View, subviewID ...string) int #### "text-direction" property @@ -1596,7 +1596,7 @@ The "text-direction" (TextDirection constant) int property determines the direct You can get the value of this property using the function - func GetTextDirection(view View, subviewID string) int + func GetTextDirection(view View, subviewID ...string) int #### "writing-mode" property The "writing-mode" (WritingMode constant) int property defines how the lines of text are arranged @@ -1612,7 +1612,7 @@ Possible values are: You can get the value of this property using the function - func GetWritingMode(view View, subviewID string) int + func GetWritingMode(view View, subviewID ...string) int #### "vertical-text-orientation" property @@ -1627,7 +1627,7 @@ Possible values are: You can get the value of this property using the function - func GetVerticalTextOrientation(view View, subviewID string) int + func GetVerticalTextOrientation(view View, subviewID ...string) int #### "user-select" property @@ -1643,7 +1643,7 @@ it will also apply to all child elements You can get the value of this property using the function - func IsUserSelect(view View, subviewID string) bool + func IsUserSelect(view View, subviewID ...string) bool ### Transformation properties @@ -1661,7 +1661,7 @@ The vanishing point is by default located in the center of the element, but it c You can get the value of this property using the function - func GetPerspective(view View, subviewID string) SizeUnit + func GetPerspective(view View, subviewID ...string) SizeUnit #### "perspective-origin-x" and "perspective-origin-y" properties @@ -1672,7 +1672,7 @@ By default, the "perspective-origin-x" and "perspective-origin-y" properties are You can get the value of these properties using the function - func GetPerspectiveOrigin(view View, subviewID string) (SizeUnit, SizeUnit) + func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) #### "backface-visibility" property @@ -1685,7 +1685,7 @@ the back face can be visible when the transformation causes the element to rotat You can get the value of this property using the function - func GetBackfaceVisible(view View, subviewID string) bool + func GetBackfaceVisible(view View, subviewID ...string) bool #### "origin-x", "origin-y", and "origin-z" properties @@ -1697,7 +1697,7 @@ The "origin-z" property is ignored if the perspective property is not set. You can get the value of these properties using the function - func GetOrigin(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) + func GetOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) #### "translate-x", "translate-y", and "translate-z" properties @@ -1708,7 +1708,7 @@ The translate-z property is ignored if the perspective property is not set. You can get the value of these properties using the function - func GetTranslate(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) + func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) #### "scale-x", "scale-y" and "scale-z" properties @@ -1721,7 +1721,7 @@ The "scale-z" property is ignored if the "perspective" property is not set. You can get the value of these properties using the function - func GetScale(view View, subviewID string) (float64, float64, float64) + func GetScale(view View, subviewID ...string) (float64, float64, float64) #### "rotate" property @@ -1738,7 +1738,7 @@ The "rotate-z" property is ignored if the "perspective" property is not set. You can get the value of these properties, as well as the "rotate" property, using the function - func GetRotate(view View, subviewID string) (float64, float64, float64, AngleUnit) + func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) #### "skew-x" and "skew-y" properties @@ -1748,7 +1748,7 @@ specified by the transform-origin-x and transform-origin-y properties. You can get the value of these properties using the function - func GetSkew(view View, subviewID string) (AngleUnit, AngleUnit) + func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) ### User data @@ -1788,8 +1788,8 @@ You can also use listeners in the following formats: You can get lists of listeners for keyboard events using the functions: - func GetKeyDownListeners(view View, subviewID string) []func(View, KeyEvent) - func GetKeyUpListeners(view View, subviewID string) []func(View, KeyEvent) + func GetKeyDownListeners(view View, subviewID ...string) []func(View, KeyEvent) + func GetKeyUpListeners(view View, subviewID ...string) []func(View, KeyEvent) ### Focus events @@ -1810,8 +1810,8 @@ You can also use a listener in the following format: You can get lists of listeners for focus events using the functions: - func GetFocusListeners(view View, subviewID string) []func(View) - func GetLostFocusListeners(view View, subviewID string) []func(View) + func GetFocusListeners(view View, subviewID ...string) []func(View) + func GetLostFocusListeners(view View, subviewID ...string) []func(View) ### Mouse events @@ -1879,14 +1879,14 @@ You can also use listeners in the following formats: You can get lists of listeners for mouse events using the functions: - func GetMouseDownListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseUpListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseMoveListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseOverListeners(view View, subviewID string) []func(View, MouseEvent) - func GetMouseOutListeners(view View, subviewID string) []func(View, MouseEvent) - func GetClickListeners(view View, subviewID string) []func(View, MouseEvent) - func GetDoubleClickListeners(view View, subviewID string) []func(View, MouseEvent) - func GetContextMenuListeners(view View, subviewID string) []func(View, MouseEvent) + func GetMouseDownListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseUpListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseMoveListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseOverListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetMouseOutListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetClickListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetDoubleClickListeners(view View, subviewID ...string) []func(View, MouseEvent) + func GetContextMenuListeners(view View, subviewID ...string) []func(View, MouseEvent) ### Pointer Events @@ -1933,12 +1933,12 @@ You can also use listeners in the following formats: You can get lists of pointer event listeners using the functions: - func GetPointerDownListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerUpListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerMoveListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerCancelListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerOverListeners(view View, subviewID string) []func(View, PointerEvent) - func GetPointerOutListeners(view View, subviewID string) []func(View, PointerEvent) + func GetPointerDownListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerUpListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerMoveListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerCancelListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerOverListeners(view View, subviewID ...string) []func(View, PointerEvent) + func GetPointerOutListeners(view View, subviewID ...string) []func(View, PointerEvent) ### Touch events @@ -1991,10 +1991,10 @@ You can also use listeners in the following formats: You can get lists of listeners for touch events using the functions: - func GetTouchStartListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchEndListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchMoveListeners(view View, subviewID string) []func(View, TouchEvent) - func GetTouchCancelListeners(view View, subviewID string) []func(View, TouchEvent) + func GetTouchStartListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchEndListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchMoveListeners(view View, subviewID ...string) []func(View, TouchEvent) + func GetTouchCancelListeners(view View, subviewID ...string) []func(View, TouchEvent) ### Resize-event @@ -2023,7 +2023,7 @@ You can also use listeners in the following formats: You can get a list of listeners for this event using the function: - func GetResizeListeners(view View, subviewID string) []func(View, Frame) + func GetResizeListeners(view View, subviewID ...string) []func(View, Frame) The current position and dimensions of the visible part of the View can be obtained using the View interface function: @@ -2031,7 +2031,7 @@ The current position and dimensions of the visible part of the View can be obtai or global function - func GetViewFrame(view View, subviewID string) Frame + func GetViewFrame(view View, subviewID ...string) Frame ### Scroll event @@ -2062,13 +2062,13 @@ The current position of the viewable area and the overall dimensions of the View or global function - func GetViewScroll(view View, subviewID string) Frame + func GetViewScroll(view View, subviewID ...string) Frame The following global functions can be used for manual scrolling func ScrollViewTo(view View, subviewID string, x, y float64) - func ScrollViewToStart(view View, subviewID string) - func ScrollViewToEnd(view View, subviewID string) + func ScrollViewToStart(view View, subviewID ...string) + func ScrollViewToEnd(view View, subviewID ...string) which scroll the view, respectively, to the given position, start and end @@ -2342,7 +2342,7 @@ on the "text-direction" property to the right or left of the previous one, and t You can get the value of this property using the function - func GetColumnCount(view View, subviewID string) int + func GetColumnCount(view View, subviewID ...string) int ### "column-width" property @@ -2353,7 +2353,7 @@ IMPORTANT! Percentages cannot be used as the "column-width" value (i.e. if you s You can get the value of this property using the function - func GetColumnWidth(view View, subviewID string) SizeUnit + func GetColumnWidth(view View, subviewID ...string) SizeUnit ### "column-gap" property @@ -2361,7 +2361,7 @@ The "column-gap" SizeUnit property (ColumnGap constant) sets the width of the ga You can get the value of this property using the function - func GetColumnGap(view View, subviewID string) SizeUnit + func GetColumnGap(view View, subviewID ...string) SizeUnit ### "column-separator" property @@ -2409,7 +2409,7 @@ not the ViewBorder structure. You can get the ViewBorders structure without additional transformations using the global function - func GetColumnSeparator(view View, subviewID string) ViewBorder + func GetColumnSeparator(view View, subviewID ...string) ViewBorder You can also set individual line attributes using the Set function of the View interface. For this, the following properties are used @@ -2447,7 +2447,7 @@ The default is "false". You can get the value of this property using the function - func GetAvoidBreak(view View, subviewID string) bool + func GetAvoidBreak(view View, subviewID ...string) bool ## StackLayout @@ -2493,7 +2493,7 @@ Example func peek(layout rui.StackLayout) { views := layout.Views() - if index := rui.GetCurrent(layout, ""); index >= 0 && index < len(views) { + if index := rui.GetCurrent(layout); index >= 0 && index < len(views) { return views[index] } return nil @@ -2561,7 +2561,7 @@ You can control the current View using the "current" integer property (constant To programmatically switch tabs, set this property to the index of the new current View. You can read the value of the "current" property using the function - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int Also, the "current" property can be used to track changes to the current View: @@ -2634,11 +2634,11 @@ Accordingly, the value "true" shows child Views, "false" - hides. You can get the value of the "expanded" property using the function - func IsDetailsExpanded(view View, subviewID string) bool + func IsDetailsExpanded(view View, subviewID ...string) bool and the value of the "summary" property can be obtained using the function - func GetDetailsSummary(view View, subviewID string) View + func GetDetailsSummary(view View, subviewID ...string) View ## Resizable @@ -2683,7 +2683,7 @@ To create a TextView, the function is used: The displayed text is set by the string property "text" (Text constant). In addition to the Get method, the value of the "text" property can be obtained using the function - func GetText (view View, subviewID string) string + func GetText (view View, subviewID ...string) string TextView inherits from View all properties of text parameters ("font-name", "text-size", "text-color", etc.). In addition to them, the "text-overflow" int property (TextOverflow constant) is added. @@ -2764,11 +2764,11 @@ relative to the bounds of the ImageView. Valid values: The following functions can be used to retrieve ImageView property values: - func GetImageViewSource(view View, subviewID string) string - func GetImageViewAltText(view View, subviewID string) string - func GetImageViewFit(view View, subviewID string) int - func GetImageViewVerticalAlign(view View, subviewID string) int - func GetImageViewHorizontalAlign(view View, subviewID string) int + func GetImageViewSource(view View, subviewID ...string) string + func GetImageViewAltText(view View, subviewID ...string) string + func GetImageViewFit(view View, subviewID ...string) int + func GetImageViewVerticalAlign(view View, subviewID ...string) int + func GetImageViewHorizontalAlign(view View, subviewID ...string) int ## EditView @@ -2821,15 +2821,15 @@ In this case, the color of the caret changes for all child EditViews placed in t The following functions can be used to get the values of the properties of an EditView: - func GetText(view View, subviewID string) string - func GetHint(view View, subviewID string) string - func GetMaxLength(view View, subviewID string) int - func GetEditViewType(view View, subviewID string) int - func GetEditViewPattern(view View, subviewID string) string - func IsReadOnly(view View, subviewID string) bool - func IsEditViewWrap(view View, subviewID string) bool - func IsSpellcheck(view View, subviewID string) bool - func GetCaretColor(view View, subviewID string) Color + func GetText(view View, subviewID ...string) string + func GetHint(view View, subviewID ...string) string + func GetMaxLength(view View, subviewID ...string) int + func GetEditViewType(view View, subviewID ...string) int + func GetEditViewPattern(view View, subviewID ...string) string + func IsReadOnly(view View, subviewID ...string) bool + func IsEditViewWrap(view View, subviewID ...string) bool + func IsSpellcheck(view View, subviewID ...string) bool + func GetCaretColor(view View, subviewID ...string) Color The "edit-text-changed" event (EditTextChangedEvent constant) is used to track changes to the text. The main event listener has the following format: @@ -2840,7 +2840,7 @@ where the second argument is the new text value You can get the current list of text change listeners using the function - func GetTextChangedListeners(view View, subviewID string) []func(EditView, string) + func GetTextChangedListeners(view View, subviewID ...string) []func(EditView, string) ## NumberPicker @@ -2873,7 +2873,7 @@ The following can be passed as a value to the "number-picker-value" property: All of these types are cast to float64. Accordingly, the Get function always returns a float64 value. The value of the "number-picker-value" property can also be read using the function: - func GetNumberPickerValue(view View, subviewID string) float64 + func GetNumberPickerValue(view View, subviewID ...string) float64 The entered values may be subject to restrictions. For this, the following properties are used: @@ -2890,8 +2890,8 @@ If "number-picker-type" is equal to NumberEditor, then the entered numbers, by d You can read the values of these properties using the functions: - func GetNumberPickerMinMax(view View, subviewID string) (float64, float64) - func GetNumberPickerStep(view View, subviewID string) float64 + func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) + func GetNumberPickerStep(view View, subviewID ...string) float64 The "number-changed" event (NumberChangedEvent constant) is used to track the change in the entered value. The main event listener has the following format: @@ -2902,7 +2902,7 @@ where the second argument is the new value You can get the current list of value change listeners using the function - func GetNumberChangedListeners(view View, subviewID string) []func(NumberPicker, float64) + func GetNumberChangedListeners(view View, subviewID ...string) []func(NumberPicker, float64) ## DatePicker @@ -2924,7 +2924,7 @@ The following can be passed as a value to the "date-picker-value" property: The text is converted to time.Time. Accordingly, the Get function always returns a time.Time value. The value of the "date-picker-value" property can also be read using the function: - func GetDatePickerValue(view View, subviewID string) time.Time + func GetDatePickerValue(view View, subviewID ...string) time.Time The dates you enter may be subject to restrictions. For this, the following properties are used: @@ -2936,9 +2936,9 @@ The dates you enter may be subject to restrictions. For this, the following prop You can read the values of these properties using the functions: - func GetDatePickerMin(view View, subviewID string) (time.Time, bool) - func GetDatePickerMax(view View, subviewID string) (time.Time, bool) - func GetDatePickerStep(view View, subviewID string) int + func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) + func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) + func GetDatePickerStep(view View, subviewID ...string) int The "date-changed" event (DateChangedEvent constant) is used to track the change in the entered value. The main event listener has the following format: @@ -2949,7 +2949,7 @@ where the second argument is the new date value You can get the current list of date change listeners using the function - func GetDateChangedListeners(view View, subviewID string) []func(DatePicker, time.Time) + func GetDateChangedListeners(view View, subviewID ...string) []func(DatePicker, time.Time) ## TimePicker @@ -2971,7 +2971,7 @@ The following can be passed as a value to the "time-picker-value" property: The text is converted to time.Time. Accordingly, the Get function always returns a time.Time value. The value of the "time-picker-value" property can also be read using the function: - func GetTimePickerValue(view View, subviewID string) time.Time + func GetTimePickerValue(view View, subviewID ...string) time.Time The time entered may be subject to restrictions. For this, the following properties are used: @@ -2983,9 +2983,9 @@ The time entered may be subject to restrictions. For this, the following propert You can read the values of these properties using the functions: - func GetTimePickerMin(view View, subviewID string) (time.Time, bool) - func GetTimePickerMax(view View, subviewID string) (time.Time, bool) - func GetTimePickerStep(view View, subviewID string) int + func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) + func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) + func GetTimePickerStep(view View, subviewID ...string) int The "time-changed" event (TimeChangedEvent constant) is used to track the change in the entered value. The main event listener has the following format: @@ -2996,7 +2996,7 @@ where the second argument is the new time value You can get the current list of date change listeners using the function - func GetTimeChangedListeners(view View, subviewID string) []func(TimePicker, time.Time) + func GetTimeChangedListeners(view View, subviewID ...string) []func(TimePicker, time.Time) ## ColorPicker @@ -3015,7 +3015,7 @@ The following can be passed as a value to the "color-picker-value" property: The value of the property "color-picker-value" can also be read using the function: - func GetColorPickerValue(view View, subviewID string) Color + func GetColorPickerValue(view View, subviewID ...string) Color The "color-changed" event (ColorChangedEvent constant) is used to track the change in the selected color. The main event listener has the following format: @@ -3026,7 +3026,7 @@ where the second argument is the new color value You can get the current list of date change listeners using the function - func GetColorChangedListeners(view View, subviewID string) []func(ColorPicker, Color) + func GetColorChangedListeners(view View, subviewID ...string) []func(ColorPicker, Color) ## FilePicker @@ -3055,7 +3055,7 @@ Two functions of the FilePicker interface are used to access the selected files: as well as the corresponding global functions - func GetFilePickerFiles(view View, subviewID string) []FileInfo + func GetFilePickerFiles(view View, subviewID ...string) []FileInfo func LoadFilePickerFile(view View, subviewID string, file FileInfo, result func(FileInfo, []byte)) The Files/GetFilePickerFiles functions return a list of the selected files as a slice of FileInfo structures. @@ -3109,7 +3109,7 @@ where the second argument is the new value of the list of selected files. You can get the current list of listeners of the list of files changing using the function - func GetFileSelectedListeners(view View, subviewID string) []func(FilePicker, []FileInfo) + func GetFileSelectedListeners(view View, subviewID ...string) []func(FilePicker, []FileInfo) ## DropDownList @@ -3130,7 +3130,7 @@ float32, float64, int, int8 … int64, uint, uint8 … uint64. All of these data types are converted to []string and assigned to the "items" property. You can read the value of the "items" property using the function - func GetDropDownItems(view View, subviewID string) []string + func GetDropDownItems(view View, subviewID ...string) []string You can disable the selection of individual items. For this, the "disabled-items" property (constant DisabledItems) is used. This property is assigned an array of disabled item indices. The index can be specified either as a number, as text, or as a constant. Therefore, the following data types can be assigned to the "disabled-items" property: @@ -3144,12 +3144,12 @@ This property is assigned an array of disabled item indices. The index can be sp All of these data types are converted to []any and assigned to the "disabled-items" property. You can read the value of the "disabled-items" property using the function - func GetDropDownDisabledItems(view View, subviewID string) []int + func GetDropDownDisabledItems(view View, subviewID ...string) []int The selected value is determined by the int property "current" (Current constant). The default is 0. You can read the value of this property using the function - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int To track the change of the "current" property, the "drop-down-event" event (DropDownEvent constant) is used. The main event listener has the following format: @@ -3160,7 +3160,7 @@ where the second argument is the index of the selected item You can get the current list of date change listeners using the function - func GetDropDownListeners(view View, subviewID string) []func(DropDownList, int) + func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, int) ## ProgressBar @@ -3179,8 +3179,8 @@ In addition to float64, float32, int, int8 … int64, uint, uint8 … uint64 You can read the value of these properties using the functions - func GetProgressBarMax(view View, subviewID string) float64 - func GetProgressBarValue(view View, subviewID string) float64 + func GetProgressBarMax(view View, subviewID ...string) float64 + func GetProgressBarValue(view View, subviewID ...string) float64 ## Button @@ -3239,7 +3239,7 @@ When assigning, all types except View and string are converted to string, then a and from the resulting View array using the NewViewListAdapter function, a ListAdapter is obtained. If the list items change during operation, then after the change, either the ReloadListViewData() -function of the ListView interface or the global ReloadListViewData(view View, subviewID string) function must be called. +function of the ListView interface or the global ReloadListViewData(view View, subviewID ...string) function must be called. These functions update the displayed list items. ### "Orientation" property @@ -3261,7 +3261,7 @@ on the value of the "text-direction" property. For languages written from right You can get the value of this property using the function - func GetListOrientation(view View, subviewID string) int + func GetListOrientation(view View, subviewID ...string) int ### "wrap" property @@ -3278,7 +3278,7 @@ the beginning (for the position of the beginning and end, see above), the new li You can get the value of this property using the function - func GetListWrap(view View, subviewID string) int + func GetListWrap(view View, subviewID ...string) int ### "item-width" and "item-height" properties @@ -3291,8 +3291,8 @@ properties "item-width" and "item-height" You can get the values of these properties using the functions - func GetListItemWidth(view View, subviewID string) SizeUnit - func GetListItemHeight(view View, subviewID string) SizeUnit + func GetListItemWidth(view View, subviewID ...string) SizeUnit + func GetListItemHeight(view View, subviewID ...string) SizeUnit ### "item-vertical-align" property @@ -3308,7 +3308,7 @@ of the contents of the list items. Valid values: You can get the value of this property using the function - func GetListItemVerticalAlign(view View, subviewID string) int + func GetListItemVerticalAlign(view View, subviewID ...string) int ### "item-horizontal-align" property @@ -3324,7 +3324,7 @@ horizontal alignment of the contents of the list items. Valid values: You can get the value of this property using the function - GetListItemHorizontalAlign(view View, subviewID string) int + GetListItemHorizontalAlign(view View, subviewID ...string) int ### "current" property @@ -3335,7 +3335,7 @@ The value "current" is less than 0 means that no item is selected You can get the value of this property using the function - func GetCurrent(view View, subviewID string) int + func GetCurrent(view View, subviewID ...string) int ### "list-item-style", "current-style", and "current-inactive-style" properties @@ -3363,13 +3363,13 @@ can take the following values You can get the value of this property using the function - func GetListViewCheckbox(view View, subviewID string) int + func GetListViewCheckbox(view View, subviewID ...string) int You can get/set the list of checked items using the "checked" property (Checked constant). This property is of type []int and stores the indexes of the marked elements. You can get the value of this property using the function - func GetListViewCheckedItems(view View, subviewID string) []int + func GetListViewCheckedItems(view View, subviewID ...string) []int You can check if a specific element is marked using the function @@ -3400,8 +3400,8 @@ In this case, the checkbox is centered horizontally, the content is below You can get property values for "checkbox-horizontal-align" and "checkbox-vertical-align" using the functions - func GetListViewCheckboxHorizontalAlign(view View, subviewID string) int - func GetListViewCheckboxVerticalAlign(view View, subviewID string) int + func GetListViewCheckboxHorizontalAlign(view View, subviewID ...string) int + func GetListViewCheckboxVerticalAlign(view View, subviewID ...string) int ### ListView events @@ -3421,9 +3421,9 @@ Where the second argument is an array of indexes of the tagged items. You can get lists of listeners for these events using the functions: - func GetListItemClickedListeners(view View, subviewID string) []func(ListView, int) - func GetListItemSelectedListeners(view View, subviewID string) []func(ListView, int) - func GetListItemCheckedListeners(view View, subviewID string) []func(ListView, []int) + func GetListItemClickedListeners(view View, subviewID ...string) []func(ListView, int) + func GetListItemSelectedListeners(view View, subviewID ...string) []func(ListView, int) + func GetListItemCheckedListeners(view View, subviewID ...string) []func(ListView, []int) ## TableView @@ -3617,7 +3617,7 @@ For horizontal alignment, use the "text-align" property You can get the value of this property using the function - func GetTableVerticalAlign(view View, subviewID string) int + func GetTableVerticalAlign(view View, subviewID ...string) int ### "selection-mode" property @@ -3636,7 +3636,7 @@ In this mode, the table generates two types of events: "table-row-selected" and You can get the value of this property using the function - func GetSelectionMode(view View, subviewID string) int + func GetSelectionMode(view View, subviewID ...string) int ### "current" property @@ -3653,7 +3653,7 @@ the "current" property can be assigned a value of type int (row index). You can get the value of this property using the function - func GetTableCurrent(view View, subviewID string) CellIndex + func GetTableCurrent(view View, subviewID ...string) CellIndex ### "allow-selection" property @@ -4603,7 +4603,7 @@ Calling the SetAnimated function does not change the value of the "transition" p To get the current list of permanent transition animations, use the function - func GetTransition(view View, subviewID string) Params + func GetTransition(view View, subviewID ...string) Params It is recommended to add new transition animations using the function @@ -4640,10 +4640,10 @@ You can also use a listener in the following format: Get lists of listeners for transition animation events using functions: - func GetTransitionRunListeners(view View, subviewID string) []func(View, string) - func GetTransitionStartListeners(view View, subviewID string) []func(View, string) - func GetTransitionEndListeners(view View, subviewID string) []func(View, string) - func GetTransitionCancelListeners(view View, subviewID string) []func(View, string) + func GetTransitionRunListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionStartListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionEndListeners(view View, subviewID ...string) []func(View, string) + func GetTransitionCancelListeners(view View, subviewID ...string) []func(View, string) ### Animation script @@ -4772,10 +4772,10 @@ You can also use a listener in the following format: Get lists of animation event listeners using functions: - func GetAnimationStartListeners(view View, subviewID string) []func(View, string) - func GetAnimationEndListeners(view View, subviewID string) []func(View, string) - func GetAnimationCancelListeners(view View, subviewID string) []func(View, string) - func GetAnimationIterationListeners(view View, subviewID string) []func(View, string) + func GetAnimationStartListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationEndListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationCancelListeners(view View, subviewID ...string) []func(View, string) + func GetAnimationIterationListeners(view View, subviewID ...string) []func(View, string) ## Session diff --git a/animation.go b/animation.go index 5578118..21287ab 100644 --- a/animation.go +++ b/animation.go @@ -747,16 +747,16 @@ func SetAnimated(rootView View, viewID, tag string, value any, animation Animati } // IsAnimationPaused returns "true" if an animation of the subview is paused, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsAnimationPaused(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsAnimationPaused(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, AnimationPaused, false) } // GetTransitions returns the subview transitions. The result is always non-nil. -// If the second argument (subviewID) is "" then transitions of the first argument (view) is returned -func GetTransitions(view View, subviewID string) map[string]Animation { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned +func GetTransitions(view View, subviewID ...string) map[string]Animation { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -767,7 +767,7 @@ func GetTransitions(view View, subviewID string) map[string]Animation { } // GetTransition returns the subview property transition. If there is no transition for the given property then nil is returned. -// If the second argument (subviewID) is "" then transitions of the first argument (view) is returned +// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned func GetTransition(view View, subviewID, tag string) Animation { if subviewID != "" { view = ViewByID(view, subviewID) @@ -781,7 +781,7 @@ func GetTransition(view View, subviewID, tag string) Animation { } // AddTransition adds the transition for the subview property. -// If the second argument (subviewID) is "" then the transition is added to the first argument (view) +// If the second argument (subviewID) is not specified or it is "" then the transition is added to the first argument (view) func AddTransition(view View, subviewID, tag string, animation Animation) bool { if tag != "" { if subviewID != "" { @@ -797,10 +797,10 @@ func AddTransition(view View, subviewID, tag string, animation Animation) bool { } // GetAnimation returns the subview animations. The result is always non-nil. -// If the second argument (subviewID) is "" then transitions of the first argument (view) is returned -func GetAnimation(view View, subviewID string) []Animation { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then transitions of the first argument (view) is returned +func GetAnimation(view View, subviewID ...string) []Animation { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { diff --git a/animationEvents.go b/animationEvents.go index fc774c0..bdebde9 100644 --- a/animationEvents.go +++ b/animationEvents.go @@ -111,7 +111,7 @@ func (view *viewData) handleTransitionEvents(tag string, data DataObject) { } } - for _, listener := range getEventListeners[View, string](view, "", tag) { + for _, listener := range getEventListeners[View, string](view, nil, tag) { listener(view, property) } } @@ -164,10 +164,10 @@ func animationEventsHtml(view View, buffer *strings.Builder) { } func (view *viewData) handleAnimationEvents(tag string, data DataObject) { - if listeners := getEventListeners[View, string](view, "", tag); len(listeners) > 0 { + if listeners := getEventListeners[View, string](view, nil, tag); len(listeners) > 0 { id := "" if name, ok := data.PropertyValue("name"); ok { - for _, animation := range GetAnimation(view, "") { + for _, animation := range GetAnimation(view) { if name == animation.animationName() { id, _ = stringProperty(animation, ID, view.Session()) } @@ -181,56 +181,56 @@ func (view *viewData) handleAnimationEvents(tag string, data DataObject) { // GetTransitionRunListeners returns the "transition-run-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTransitionRunListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTransitionRunListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, TransitionRunEvent) } // GetTransitionStartListeners returns the "transition-start-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTransitionStartListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTransitionStartListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, TransitionStartEvent) } // GetTransitionEndListeners returns the "transition-end-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTransitionEndListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTransitionEndListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, TransitionEndEvent) } // GetTransitionCancelListeners returns the "transition-cancel-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTransitionCancelListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTransitionCancelListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, TransitionCancelEvent) } // GetAnimationStartListeners returns the "animation-start-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetAnimationStartListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetAnimationStartListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, AnimationStartEvent) } // GetAnimationEndListeners returns the "animation-end-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetAnimationEndListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetAnimationEndListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, AnimationEndEvent) } // GetAnimationCancelListeners returns the "animation-cancel-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetAnimationCancelListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetAnimationCancelListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, AnimationCancelEvent) } // GetAnimationIterationListeners returns the "animation-iteration-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetAnimationIterationListeners(view View, subviewID string) []func(View, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetAnimationIterationListeners(view View, subviewID ...string) []func(View, string) { return getEventListeners[View, string](view, subviewID, AnimationIterationEvent) } diff --git a/checkbox.go b/checkbox.go index 1dd0188..4248686 100644 --- a/checkbox.go +++ b/checkbox.go @@ -194,14 +194,14 @@ func (button *checkboxData) changedCheckboxState(state bool) { } func checkboxClickListener(view View) { - view.Set(Checked, !IsCheckboxChecked(view, "")) + view.Set(Checked, !IsCheckboxChecked(view)) BlurView(view) } func checkboxKeyListener(view View, event KeyEvent) { switch event.Code { case "Enter", "Space": - view.Set(Checked, !IsCheckboxChecked(view, "")) + view.Set(Checked, !IsCheckboxChecked(view)) } } @@ -218,8 +218,8 @@ func (button *checkboxData) setChangedListener(value any) bool { func (button *checkboxData) cssStyle(self View, builder cssBuilder) { session := button.Session() - vAlign := GetCheckboxVerticalAlign(button, "") - hAlign := GetCheckboxHorizontalAlign(button, "") + vAlign := GetCheckboxVerticalAlign(button) + hAlign := GetCheckboxHorizontalAlign(button) switch hAlign { case CenterAlign: if vAlign == BottomAlign { @@ -246,8 +246,8 @@ func (button *checkboxData) cssStyle(self View, builder cssBuilder) { } func (button *checkboxData) htmlCheckbox(buffer *strings.Builder, checked bool) (int, int) { - vAlign := GetCheckboxVerticalAlign(button, "") - hAlign := GetCheckboxHorizontalAlign(button, "") + vAlign := GetCheckboxVerticalAlign(button) + hAlign := GetCheckboxHorizontalAlign(button) buffer.WriteString(`
= 0 && align < len(values) { return values[align] @@ -331,7 +331,7 @@ func (button *checkboxData) cssHorizontalAlign() string { } func (button *checkboxData) cssVerticalAlign() string { - align := GetVerticalAlign(button, "") + align := GetVerticalAlign(button) values := enumProperties[CellVerticalAlign].cssValues if align >= 0 && align < len(values) { return values[align] @@ -340,29 +340,19 @@ func (button *checkboxData) cssVerticalAlign() string { } // IsCheckboxChecked returns true if the Checkbox is checked, false otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsCheckboxChecked(view View, subviewID string) bool { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if checked := view.Get(Checked); checked != nil { - if b, ok := checked.(bool); ok { - return b - } - } - } - return false +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsCheckboxChecked(view View, subviewID ...string) bool { + return boolStyledProperty(view, subviewID, Checked, false) } // GetCheckboxVerticalAlign return the vertical align of a Checkbox subview: TopAlign (0), BottomAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetCheckboxVerticalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetCheckboxVerticalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, CheckboxVerticalAlign, LeftAlign, false) } // GetCheckboxHorizontalAlign return the vertical align of a Checkbox subview: LeftAlign (0), RightAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetCheckboxHorizontalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetCheckboxHorizontalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, CheckboxHorizontalAlign, TopAlign, false) } diff --git a/colorPicker.go b/colorPicker.go index b06c953..0d95803 100644 --- a/colorPicker.go +++ b/colorPicker.go @@ -66,7 +66,7 @@ func (picker *colorPickerData) remove(tag string) { } case ColorPickerValue: - oldColor := GetColorPickerValue(picker, "") + oldColor := GetColorPickerValue(picker) delete(picker.properties, ColorPickerValue) picker.colorChanged(oldColor) @@ -99,7 +99,7 @@ func (picker *colorPickerData) set(tag string, value any) bool { return true case ColorPickerValue: - oldColor := GetColorPickerValue(picker, "") + oldColor := GetColorPickerValue(picker) if picker.setColorProperty(ColorPickerValue, value) { picker.colorChanged(oldColor) return true @@ -112,7 +112,7 @@ func (picker *colorPickerData) set(tag string, value any) bool { } func (picker *colorPickerData) colorChanged(oldColor Color) { - if newColor := GetColorPickerValue(picker, ""); oldColor != newColor { + if newColor := GetColorPickerValue(picker); oldColor != newColor { if picker.created { picker.session.runScript(fmt.Sprintf(`setInputValue('%s', '%s')`, picker.htmlID(), newColor.rgbString())) } @@ -145,7 +145,7 @@ func (picker *colorPickerData) htmlProperties(self View, buffer *strings.Builder picker.viewData.htmlProperties(self, buffer) buffer.WriteString(` type="color" value="`) - buffer.WriteString(GetColorPickerValue(picker, "").rgbString()) + buffer.WriteString(GetColorPickerValue(picker).rgbString()) buffer.WriteByte('"') buffer.WriteString(` oninput="editViewInputEvent(this)"`) @@ -155,7 +155,7 @@ func (picker *colorPickerData) htmlProperties(self View, buffer *strings.Builder } func (picker *colorPickerData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } picker.viewData.htmlDisabledProperties(self, buffer) @@ -165,7 +165,7 @@ func (picker *colorPickerData) handleCommand(self View, command string, data Dat switch command { case "textChanged": if text, ok := data.PropertyValue("text"); ok { - oldColor := GetColorPickerValue(picker, "") + oldColor := GetColorPickerValue(picker) if color, ok := StringToColor(text); ok { picker.properties[ColorPickerValue] = color if color != oldColor { @@ -182,10 +182,10 @@ func (picker *colorPickerData) handleCommand(self View, command string, data Dat } // GetColorPickerValue returns the value of ColorPicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetColorPickerValue(view View, subviewID string) Color { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetColorPickerValue(view View, subviewID ...string) Color { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value, ok := colorProperty(view, ColorPickerValue, view.Session()); ok { @@ -204,7 +204,7 @@ func GetColorPickerValue(view View, subviewID string) Color { // GetColorChangedListeners returns the ColorChangedListener list of an ColorPicker subview. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetColorChangedListeners(view View, subviewID string) []func(ColorPicker, Color) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetColorChangedListeners(view View, subviewID ...string) []func(ColorPicker, Color) { return getEventListeners[ColorPicker, Color](view, subviewID, ColorChangedEvent) } diff --git a/columnLayout.go b/columnLayout.go index b6b032c..c9032e7 100644 --- a/columnLayout.go +++ b/columnLayout.go @@ -137,29 +137,26 @@ func (columnLayout *columnLayoutData) set(tag string, value any) bool { // GetColumnCount returns int value which specifies number of columns into which the content of // ColumnLayout is break. If the return value is 0 then the number of columns is calculated // based on the "column-width" property. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnCount(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnCount(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, ColumnCount, 0) } // GetColumnWidth returns SizeUnit value which specifies the width of each column of ColumnLayout. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnWidth(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnWidth(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, ColumnWidth, false) } // GetColumnGap returns SizeUnit property which specifies the size of the gap (gutter) between columns of ColumnLayout. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnGap(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnGap(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, ColumnGap, false) } -// GetColumnSeparator returns ViewBorder struct which specifies the line drawn between -// columns in a multi-column ColumnLayout. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnSeparator(view View, subviewID string) ViewBorder { - if subviewID != "" { - view = ViewByID(view, subviewID) +func getColumnSeparator(view View, subviewID []string) ViewBorder { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -178,27 +175,34 @@ func GetColumnSeparator(view View, subviewID string) ViewBorder { return ViewBorder{} } +// GetColumnSeparator returns ViewBorder struct which specifies the line drawn between +// columns in a multi-column ColumnLayout. +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnSeparator(view View, subviewID ...string) ViewBorder { + return getColumnSeparator(view, subviewID) +} + // ColumnSeparatorStyle returns int value which specifies the style of the line drawn between // columns in a multi-column layout. // Valid values are NoneLine (0), SolidLine (1), DashedLine (2), DottedLine (3), and DoubleLine (4). -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnSeparatorStyle(view View, subviewID string) int { - border := GetColumnSeparator(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnSeparatorStyle(view View, subviewID ...string) int { + border := getColumnSeparator(view, subviewID) return border.Style } // ColumnSeparatorWidth returns SizeUnit value which specifies the width of the line drawn between // columns in a multi-column layout. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnSeparatorWidth(view View, subviewID string) SizeUnit { - border := GetColumnSeparator(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnSeparatorWidth(view View, subviewID ...string) SizeUnit { + border := getColumnSeparator(view, subviewID) return border.Width } // ColumnSeparatorColor returns Color value which specifies the color of the line drawn between // columns in a multi-column layout. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetColumnSeparatorColor(view View, subviewID string) Color { - border := GetColumnSeparator(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetColumnSeparatorColor(view View, subviewID ...string) Color { + border := getColumnSeparator(view, subviewID) return border.Color } diff --git a/datePicker.go b/datePicker.go index 9254693..da45faa 100644 --- a/datePicker.go +++ b/datePicker.go @@ -96,7 +96,7 @@ func (picker *datePickerData) remove(tag string) { case DatePickerValue: if _, ok := picker.properties[DatePickerValue]; ok { delete(picker.properties, DatePickerValue) - date := GetDatePickerValue(picker, "") + date := GetDatePickerValue(picker) if picker.created { picker.session.runScript(fmt.Sprintf(`setInputValue('%s', '%s')`, picker.htmlID(), date.Format(dateFormat))) } @@ -204,9 +204,9 @@ func (picker *datePickerData) set(tag string, value any) bool { } case DatePickerStep: - oldStep := GetDatePickerStep(picker, "") + oldStep := GetDatePickerStep(picker) if picker.setIntProperty(DatePickerStep, value) { - if step := GetDatePickerStep(picker, ""); oldStep != step { + if step := GetDatePickerStep(picker); oldStep != step { if picker.created { if step > 0 { updateProperty(picker.htmlID(), Step, strconv.Itoa(step), picker.session) @@ -220,7 +220,7 @@ func (picker *datePickerData) set(tag string, value any) bool { } case DatePickerValue: - oldDate := GetDatePickerValue(picker, "") + oldDate := GetDatePickerValue(picker) if date, ok := setTimeValue(DatePickerValue); ok { if date != oldDate { if picker.created { @@ -294,7 +294,7 @@ func (picker *datePickerData) htmlProperties(self View, buffer *strings.Builder) } buffer.WriteString(` value="`) - buffer.WriteString(GetDatePickerValue(picker, "").Format(dateFormat)) + buffer.WriteString(GetDatePickerValue(picker).Format(dateFormat)) buffer.WriteByte('"') buffer.WriteString(` oninput="editViewInputEvent(this)"`) @@ -304,7 +304,7 @@ func (picker *datePickerData) htmlProperties(self View, buffer *strings.Builder) } func (picker *datePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } picker.viewData.htmlDisabledProperties(self, buffer) @@ -315,7 +315,7 @@ func (picker *datePickerData) handleCommand(self View, command string, data Data case "textChanged": if text, ok := data.PropertyValue("text"); ok { if value, err := time.Parse(dateFormat, text); err == nil { - oldValue := GetDatePickerValue(picker, "") + oldValue := GetDatePickerValue(picker) picker.properties[DatePickerValue] = value if value != oldValue { for _, listener := range picker.dateChangedListeners { @@ -365,10 +365,10 @@ func getDateProperty(view View, mainTag, shortTag string) (time.Time, bool) { // GetDatePickerMin returns the min date of DatePicker subview and "true" as the second value if the min date is set, // "false" as the second value otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDatePickerMin(view View, subviewID string) (time.Time, bool) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDatePickerMin(view View, subviewID ...string) (time.Time, bool) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getDateProperty(view, DatePickerMin, Min) @@ -378,10 +378,10 @@ func GetDatePickerMin(view View, subviewID string) (time.Time, bool) { // GetDatePickerMax returns the max date of DatePicker subview and "true" as the second value if the min date is set, // "false" as the second value otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDatePickerMax(view View, subviewID string) (time.Time, bool) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDatePickerMax(view View, subviewID ...string) (time.Time, bool) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getDateProperty(view, DatePickerMax, Max) @@ -390,16 +390,16 @@ func GetDatePickerMax(view View, subviewID string) (time.Time, bool) { } // GetDatePickerStep returns the date changing step in days of DatePicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDatePickerStep(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDatePickerStep(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, DatePickerStep, 0) } // GetDatePickerValue returns the date of DatePicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDatePickerValue(view View, subviewID string) time.Time { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDatePickerValue(view View, subviewID ...string) time.Time { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return time.Now() @@ -410,7 +410,7 @@ func GetDatePickerValue(view View, subviewID string) time.Time { // GetDateChangedListeners returns the DateChangedListener list of an DatePicker subview. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDateChangedListeners(view View, subviewID string) []func(DatePicker, time.Time) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDateChangedListeners(view View, subviewID ...string) []func(DatePicker, time.Time) { return getEventListeners[DatePicker, time.Time](view, subviewID, DateChangedEvent) } diff --git a/detailsView.go b/detailsView.go index 7955723..5eedbec 100644 --- a/detailsView.go +++ b/detailsView.go @@ -110,7 +110,7 @@ func (detailsView *detailsViewData) set(tag string, value any) bool { return false } if detailsView.created { - if IsDetailsExpanded(detailsView, "") { + if IsDetailsExpanded(detailsView) { updateProperty(detailsView.htmlID(), "open", "", detailsView.Session()) } else { removeProperty(detailsView.htmlID(), "open", detailsView.Session()) @@ -148,7 +148,7 @@ func (detailsView *detailsViewData) htmlTag() string { func (detailsView *detailsViewData) htmlProperties(self View, buffer *strings.Builder) { detailsView.viewsContainerData.htmlProperties(self, buffer) buffer.WriteString(` ontoggle="detailsEvent(this)"`) - if IsDetailsExpanded(detailsView, "") { + if IsDetailsExpanded(detailsView) { buffer.WriteString(` open`) } } @@ -157,7 +157,7 @@ func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Buil if value, ok := detailsView.properties[Summary]; ok { switch value := value.(type) { case string: - if !GetNotTranslate(detailsView, "") { + if !GetNotTranslate(detailsView) { value, _ = detailsView.session.GetString(value) } buffer.WriteString("") @@ -186,10 +186,10 @@ func (detailsView *detailsViewData) handleCommand(self View, command string, dat } // GetDetailsSummary returns a value of the Summary property of DetailsView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDetailsSummary(view View, subviewID string) View { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDetailsSummary(view View, subviewID ...string) View { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.Get(Summary); value != nil { @@ -206,7 +206,7 @@ func GetDetailsSummary(view View, subviewID string) View { } // IsDetailsExpanded returns a value of the Expanded property of DetailsView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsDetailsExpanded(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsDetailsExpanded(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Expanded, false) } diff --git a/dropDownList.go b/dropDownList.go index c770b39..bc1f0d4 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -80,7 +80,7 @@ func (list *dropDownListData) remove(tag string) { } case Current: - oldCurrent := GetCurrent(list, "") + oldCurrent := GetCurrent(list) delete(list.properties, Current) if oldCurrent != 0 { if list.created { @@ -125,12 +125,12 @@ func (list *dropDownListData) set(tag string, value any) bool { return true case Current: - oldCurrent := GetCurrent(list, "") + oldCurrent := GetCurrent(list) if !list.setIntProperty(Current, value) { return false } - if current := GetCurrent(list, ""); oldCurrent != current { + if current := GetCurrent(list); oldCurrent != current { if list.created { list.session.runScript(fmt.Sprintf(`selectDropDownListItem('%s', %d)`, list.htmlID(), current)) } @@ -333,9 +333,9 @@ func (list *dropDownListData) htmlTag() string { func (list *dropDownListData) htmlSubviews(self View, buffer *strings.Builder) { if list.items != nil { - current := GetCurrent(list, "") - notTranslate := GetNotTranslate(list, "") - disabledItems := GetDropDownDisabledItems(list, "") + current := GetCurrent(list) + notTranslate := GetNotTranslate(list) + disabledItems := GetDropDownDisabledItems(list) for i, item := range list.items { disabled := false for _, index := range disabledItems { @@ -369,7 +369,7 @@ func (list *dropDownListData) htmlProperties(self View, buffer *strings.Builder) func (list *dropDownListData) htmlDisabledProperties(self View, buffer *strings.Builder) { list.viewData.htmlDisabledProperties(self, buffer) - if IsDisabled(list, "") { + if IsDisabled(list) { buffer.WriteString(`disabled`) } } @@ -386,7 +386,7 @@ func (list *dropDownListData) handleCommand(self View, command string, data Data case "itemSelected": if text, ok := data.PropertyValue("number"); ok { if number, err := strconv.Atoi(text); err == nil { - if GetCurrent(list, "") != number && number >= 0 && number < len(list.items) { + if GetCurrent(list) != number && number >= 0 && number < len(list.items) { list.properties[Current] = number list.onSelectedItemChanged(number) } @@ -401,19 +401,17 @@ func (list *dropDownListData) handleCommand(self View, command string, data Data return true } -func GetDropDownListeners(view View) []func(DropDownList, int) { - if value := view.Get(DropDownEvent); value != nil { - if listeners, ok := value.([]func(DropDownList, int)); ok { - return listeners - } - } - return []func(DropDownList, int){} +// GetDropDownListeners returns the "drop-down-event" listener list. If there are no listeners then the empty list is returned. +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, int) { + return getEventListeners[DropDownList, int](view, subviewID, DropDownEvent) } -// func GetDropDownItems return the view items list -func GetDropDownItems(view View, subviewID string) []string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// GetDropDownItems return the DropDownList items list. +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDropDownItems(view View, subviewID ...string) []string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if list, ok := view.(DropDownList); ok { @@ -423,11 +421,13 @@ func GetDropDownItems(view View, subviewID string) []string { return []string{} } -// func GetDropDownDisabledItems return the list of disabled item indexes -func GetDropDownDisabledItems(view View, subviewID string) []int { - if subviewID != "" { - view = ViewByID(view, subviewID) +// GetDropDownDisabledItems return the list of DropDownList disabled item indexes. +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDropDownDisabledItems(view View, subviewID ...string) []int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value := view.Get(DisabledItems); value != nil { if values, ok := value.([]any); ok { diff --git a/editView.go b/editView.go index b14fb58..73cf5f9 100644 --- a/editView.go +++ b/editView.go @@ -132,19 +132,19 @@ func (edit *editViewData) remove(tag string) { case Text: if exists { - oldText := GetText(edit, "") + oldText := GetText(edit) delete(edit.properties, tag) if oldText != "" { edit.textChanged("") if edit.created { - edit.session.runScript(fmt.Sprintf(`setInputValue('%s', '%s')`, edit.htmlID(), "")) + edit.session.runScript(fmt.Sprintf(`setInputValue('%s', '%s')`, edit.htmlID())) } } } case EditViewPattern: if exists { - oldText := GetEditViewPattern(edit, "") + oldText := GetEditViewPattern(edit) delete(edit.properties, tag) if oldText != "" { if edit.created { @@ -156,7 +156,7 @@ func (edit *editViewData) remove(tag string) { case EditViewType: if exists { - oldType := GetEditViewType(edit, "") + oldType := GetEditViewType(edit) delete(edit.properties, tag) if oldType != 0 { if edit.created { @@ -168,10 +168,10 @@ func (edit *editViewData) remove(tag string) { case EditWrap: if exists { - oldWrap := IsEditViewWrap(edit, "") + oldWrap := IsEditViewWrap(edit) delete(edit.properties, tag) - if GetEditViewType(edit, "") == MultiLineText { - if wrap := IsEditViewWrap(edit, ""); wrap != oldWrap { + if GetEditViewType(edit) == MultiLineText { + if wrap := IsEditViewWrap(edit); wrap != oldWrap { if edit.created { if wrap { updateProperty(edit.htmlID(), "wrap", "soft", edit.session) @@ -202,13 +202,13 @@ func (edit *editViewData) set(tag string, value any) bool { switch tag { case Text: - oldText := GetText(edit, "") + oldText := GetText(edit) if text, ok := value.(string); ok { edit.properties[Text] = text - if text = GetText(edit, ""); oldText != text { + if text = GetText(edit); oldText != text { edit.textChanged(text) if edit.created { - if GetEditViewType(edit, "") == MultiLineText { + if GetEditViewType(edit) == MultiLineText { updateInnerHTML(edit.htmlID(), edit.Session()) } else { text = strings.ReplaceAll(text, `"`, `\"`) @@ -224,10 +224,10 @@ func (edit *editViewData) set(tag string, value any) bool { return false case Hint: - oldText := GetHint(edit, "") + oldText := GetHint(edit) if text, ok := value.(string); ok { edit.properties[Hint] = text - if text = GetHint(edit, ""); oldText != text { + if text = GetHint(edit); oldText != text { if edit.created { if text != "" { updateProperty(edit.htmlID(), "placeholder", text, edit.session) @@ -242,9 +242,9 @@ func (edit *editViewData) set(tag string, value any) bool { return false case MaxLength: - oldMaxLength := GetMaxLength(edit, "") + oldMaxLength := GetMaxLength(edit) if edit.setIntProperty(MaxLength, value) { - if maxLength := GetMaxLength(edit, ""); maxLength != oldMaxLength { + if maxLength := GetMaxLength(edit); maxLength != oldMaxLength { if edit.created { if maxLength > 0 { updateProperty(edit.htmlID(), "maxlength", strconv.Itoa(maxLength), edit.session) @@ -261,7 +261,7 @@ func (edit *editViewData) set(tag string, value any) bool { case ReadOnly: if edit.setBoolProperty(ReadOnly, value) { if edit.created { - if IsReadOnly(edit, "") { + if IsReadOnly(edit) { updateProperty(edit.htmlID(), ReadOnly, "", edit.session) } else { removeProperty(edit.htmlID(), ReadOnly, edit.session) @@ -275,7 +275,7 @@ func (edit *editViewData) set(tag string, value any) bool { case Spellcheck: if edit.setBoolProperty(Spellcheck, value) { if edit.created { - updateBoolProperty(edit.htmlID(), Spellcheck, IsSpellcheck(edit, ""), edit.session) + updateBoolProperty(edit.htmlID(), Spellcheck, IsSpellcheck(edit), edit.session) } edit.propertyChangedEvent(tag) return true @@ -283,10 +283,10 @@ func (edit *editViewData) set(tag string, value any) bool { return false case EditViewPattern: - oldText := GetEditViewPattern(edit, "") + oldText := GetEditViewPattern(edit) if text, ok := value.(string); ok { edit.properties[EditViewPattern] = text - if text = GetEditViewPattern(edit, ""); oldText != text { + if text = GetEditViewPattern(edit); oldText != text { if edit.created { if text != "" { updateProperty(edit.htmlID(), Pattern, text, edit.session) @@ -301,9 +301,9 @@ func (edit *editViewData) set(tag string, value any) bool { return false case EditViewType: - oldType := GetEditViewType(edit, "") + oldType := GetEditViewType(edit) if edit.setEnumProperty(EditViewType, value, enumProperties[EditViewType].values) { - if GetEditViewType(edit, "") != oldType { + if GetEditViewType(edit) != oldType { if edit.created { updateInnerHTML(edit.parentHTMLID(), edit.session) } @@ -314,10 +314,10 @@ func (edit *editViewData) set(tag string, value any) bool { return false case EditWrap: - oldWrap := IsEditViewWrap(edit, "") + oldWrap := IsEditViewWrap(edit) if edit.setBoolProperty(EditWrap, value) { - if GetEditViewType(edit, "") == MultiLineText { - if wrap := IsEditViewWrap(edit, ""); wrap != oldWrap { + if GetEditViewType(edit) == MultiLineText { + if wrap := IsEditViewWrap(edit); wrap != oldWrap { if edit.created { if wrap { updateProperty(edit.htmlID(), "wrap", "soft", edit.session) @@ -360,7 +360,7 @@ func (edit *editViewData) get(tag string) any { } func (edit *editViewData) AppendText(text string) { - if GetEditViewType(edit, "") == MultiLineText { + if GetEditViewType(edit) == MultiLineText { if value := edit.getRaw(Text); value != nil { if textValue, ok := value.(string); ok { textValue += text @@ -379,7 +379,7 @@ func (edit *editViewData) AppendText(text string) { } edit.set(Text, text) } else { - edit.set(Text, GetText(edit, "")+text) + edit.set(Text, GetText(edit)+text) } } @@ -391,7 +391,7 @@ func (edit *editViewData) textChanged(newText string) { } func (edit *editViewData) htmlTag() string { - if GetEditViewType(edit, "") == MultiLineText { + if GetEditViewType(edit) == MultiLineText { return "textarea" } return "input" @@ -401,14 +401,14 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { edit.viewData.htmlProperties(self, buffer) writeSpellcheck := func() { - if spellcheck := IsSpellcheck(edit, ""); spellcheck { + if spellcheck := IsSpellcheck(edit); spellcheck { buffer.WriteString(` spellcheck="true"`) } else { buffer.WriteString(` spellcheck="false"`) } } - editType := GetEditViewType(edit, "") + editType := GetEditViewType(edit) switch editType { case SingleLineText: buffer.WriteString(` type="text" inputmode="text"`) @@ -430,7 +430,7 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { buffer.WriteString(` type="tel" inputmode="tel"`) case MultiLineText: - if IsEditViewWrap(edit, "") { + if IsEditViewWrap(edit) { buffer.WriteString(` wrap="soft"`) } else { buffer.WriteString(` wrap="off"`) @@ -438,11 +438,11 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { writeSpellcheck() } - if IsReadOnly(edit, "") { + if IsReadOnly(edit) { buffer.WriteString(` readonly`) } - if maxLength := GetMaxLength(edit, ""); maxLength > 0 { + if maxLength := GetMaxLength(edit); maxLength > 0 { buffer.WriteString(` maxlength="`) buffer.WriteString(strconv.Itoa(maxLength)) buffer.WriteByte('"') @@ -455,21 +455,21 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { return textToJS(text) } - if hint := GetHint(edit, ""); hint != "" { + if hint := GetHint(edit); hint != "" { buffer.WriteString(` placeholder="`) buffer.WriteString(convertText(hint)) buffer.WriteByte('"') } buffer.WriteString(` oninput="editViewInputEvent(this)"`) - if pattern := GetEditViewPattern(edit, ""); pattern != "" { + if pattern := GetEditViewPattern(edit); pattern != "" { buffer.WriteString(` pattern="`) buffer.WriteString(convertText(pattern)) buffer.WriteByte('"') } if editType != MultiLineText { - if text := GetText(edit, ""); text != "" { + if text := GetText(edit); text != "" { buffer.WriteString(` value="`) buffer.WriteString(convertText(text)) buffer.WriteByte('"') @@ -478,25 +478,25 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { } func (edit *editViewData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } edit.viewData.htmlDisabledProperties(self, buffer) } func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) { - if GetEditViewType(edit, "") == MultiLineText { - buffer.WriteString(textToJS(GetText(edit, ""))) + if GetEditViewType(edit) == MultiLineText { + buffer.WriteString(textToJS(GetText(edit))) } } func (edit *editViewData) handleCommand(self View, command string, data DataObject) bool { switch command { case "textChanged": - oldText := GetText(edit, "") + oldText := GetText(edit) if text, ok := data.PropertyValue("text"); ok { edit.properties[Text] = text - if text := GetText(edit, ""); text != oldText { + if text := GetText(edit); text != oldText { edit.textChanged(text) } } @@ -507,10 +507,10 @@ func (edit *editViewData) handleCommand(self View, command string, data DataObje } // GetText returns a text of the EditView subview. -// If the second argument (subviewID) is "" then a text of the first argument (view) is returned. -func GetText(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned. +func GetText(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.getRaw(Text); value != nil { @@ -523,10 +523,10 @@ func GetText(view View, subviewID string) string { } // GetHint returns a hint text of the subview. -// If the second argument (subviewID) is "" then a text of the first argument (view) is returned. -func GetHint(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a text of the first argument (view) is returned. +func GetHint(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if text, ok := stringProperty(view, Hint, view.Session()); ok { @@ -544,41 +544,41 @@ func GetHint(view View, subviewID string) string { } // GetMaxLength returns a maximal lenght of EditView. If a maximal lenght is not limited then 0 is returned -// If the second argument (subviewID) is "" then a value of the first argument (view) is returned. -func GetMaxLength(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned. +func GetMaxLength(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, MaxLength, 0) } // IsReadOnly returns the true if a EditView works in read only mode. -// If the second argument (subviewID) is "" then a value of the first argument (view) is returned. -func IsReadOnly(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned. +func IsReadOnly(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, ReadOnly, false) } // IsSpellcheck returns a value of the Spellcheck property of EditView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsSpellcheck(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsSpellcheck(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Spellcheck, false) } // GetTextChangedListeners returns the TextChangedListener list of an EditView or MultiLineEditView subview. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextChangedListeners(view View, subviewID string) []func(EditView, string) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextChangedListeners(view View, subviewID ...string) []func(EditView, string) { return getEventListeners[EditView, string](view, subviewID, EditTextChangedEvent) } // GetEditViewType returns a value of the Type property of EditView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetEditViewType(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetEditViewType(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, EditViewType, SingleLineText, false) } // GetEditViewPattern returns a value of the Pattern property of EditView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetEditViewPattern(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetEditViewPattern(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if pattern, ok := stringProperty(view, EditViewPattern, view.Session()); ok { @@ -596,13 +596,13 @@ func GetEditViewPattern(view View, subviewID string) string { } // IsEditViewWrap returns a value of the EditWrap property of MultiLineEditView. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsEditViewWrap(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsEditViewWrap(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, EditWrap, false) } // AppendEditText appends the text to the EditView content. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. func AppendEditText(view View, subviewID string, text string) { if subviewID != "" { if edit := EditViewByID(view, subviewID); edit != nil { @@ -617,7 +617,7 @@ func AppendEditText(view View, subviewID string, text string) { } // GetCaretColor returns the color of the text input carret. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCaretColor(view View, subviewID string) Color { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCaretColor(view View, subviewID ...string) Color { return colorStyledProperty(view, subviewID, CaretColor, false) } diff --git a/filePicker.go b/filePicker.go index 7f4377b..66f8fea 100644 --- a/filePicker.go +++ b/filePicker.go @@ -251,7 +251,7 @@ func (picker *filePickerData) htmlProperties(self View, buffer *strings.Builder) } buffer.WriteString(` type="file"`) - if IsMultipleFilePicker(picker, "") { + if IsMultipleFilePicker(picker) { buffer.WriteString(` multiple`) } @@ -262,7 +262,7 @@ func (picker *filePickerData) htmlProperties(self View, buffer *strings.Builder) } func (picker *filePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } picker.viewData.htmlDisabledProperties(self, buffer) @@ -334,9 +334,14 @@ func (picker *filePickerData) handleCommand(self View, command string, data Data // GetFilePickerFiles returns the list of FilePicker selected files // If there are no files selected then an empty slice is returned (the result is always not nil) -// If the second argument (subviewID) is "" then selected files of the first argument (view) is returned -func GetFilePickerFiles(view View, subviewID string) []FileInfo { - if picker := FilePickerByID(view, subviewID); picker != nil { +// If the second argument (subviewID) is not specified or it is "" then selected files of the first argument (view) is returned +func GetFilePickerFiles(view View, subviewID ...string) []FileInfo { + subview := "" + if len(subviewID) > 0 { + subview = subviewID[0] + } + + if picker := FilePickerByID(view, subview); picker != nil { return picker.Files() } return []FileInfo{} @@ -352,16 +357,16 @@ func LoadFilePickerFile(view View, subviewID string, file FileInfo, result func( } // IsMultipleFilePicker returns "true" if multiple files can be selected in the FilePicker, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsMultipleFilePicker(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsMultipleFilePicker(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Multiple, false) } // GetFilePickerAccept returns sets the list of allowed file extensions or MIME types. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetFilePickerAccept(view View, subviewID string) []string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetFilePickerAccept(view View, subviewID ...string) []string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { accept, ok := stringProperty(view, Accept, view.Session()) @@ -383,7 +388,7 @@ func GetFilePickerAccept(view View, subviewID string) []string { // GetFileSelectedListeners returns the "file-selected-event" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetFileSelectedListeners(view View, subviewID string) []func(FilePicker, []FileInfo) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetFileSelectedListeners(view View, subviewID ...string) []func(FilePicker, []FileInfo) { return getEventListeners[FilePicker, []FileInfo](view, subviewID, FileSelectedEvent) } diff --git a/focusEvents.go b/focusEvents.go index bb61e18..963f159 100644 --- a/focusEvents.go +++ b/focusEvents.go @@ -125,10 +125,11 @@ func (view *viewData) removeFocusListener(tag string) { } } -func getFocusListeners(view View, subviewID string, tag string) []func(View) { - if subviewID != "" { - view = ViewByID(view, subviewID) +func getFocusListeners(view View, subviewID []string, tag string) []func(View) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value := view.Get(tag); value != nil { if result, ok := value.([]func(View)); ok { @@ -148,13 +149,13 @@ func focusEventsHtml(view View, buffer *strings.Builder) { } // GetFocusListeners returns a FocusListener list. If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetFocusListeners(view View, subviewID string) []func(View) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetFocusListeners(view View, subviewID ...string) []func(View) { return getFocusListeners(view, subviewID, FocusEvent) } // GetLostFocusListeners returns a LostFocusListener list. If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetLostFocusListeners(view View, subviewID string) []func(View) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetLostFocusListeners(view View, subviewID ...string) []func(View) { return getFocusListeners(view, subviewID, LostFocusEvent) } diff --git a/gridLayout.go b/gridLayout.go index 4c8e443..da9a6e3 100644 --- a/gridLayout.go +++ b/gridLayout.go @@ -201,8 +201,8 @@ func (gridLayout *gridLayoutData) Get(tag string) any { func (gridLayout *gridLayoutData) get(tag string) any { if tag == Gap { - rowGap := GetGridRowGap(gridLayout, "") - columnGap := GetGridColumnGap(gridLayout, "") + rowGap := GetGridRowGap(gridLayout) + columnGap := GetGridColumnGap(gridLayout) if rowGap.Equal(columnGap) { return rowGap } @@ -319,29 +319,29 @@ func (gridLayout *gridLayoutData) cssStyle(self View, builder cssBuilder) { */ // GetCellVerticalAlign returns the vertical align of a GridLayout cell content: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCellVerticalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCellVerticalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, CellVerticalAlign, StretchAlign, false) } // GetCellHorizontalAlign returns the vertical align of a GridLayout cell content: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCellHorizontalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCellHorizontalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, CellHorizontalAlign, StretchAlign, false) } // GetGridAutoFlow returns the value of the "grid-auto-flow" property -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetGridAutoFlow(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetGridAutoFlow(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, GridAutoFlow, 0, false) } // GetCellWidth returns the width of a GridLayout cell. If the result is an empty array, then the width is not set. // If the result is a single value array, then the width of all cell is equal. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCellWidth(view View, subviewID string) []SizeUnit { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCellWidth(view View, subviewID ...string) []SizeUnit { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return gridCellSizes(view, CellWidth, view.Session()) @@ -351,10 +351,10 @@ func GetCellWidth(view View, subviewID string) []SizeUnit { // GetCellHeight returns the height of a GridLayout cell. If the result is an empty array, then the height is not set. // If the result is a single value array, then the height of all cell is equal. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCellHeight(view View, subviewID string) []SizeUnit { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCellHeight(view View, subviewID ...string) []SizeUnit { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return gridCellSizes(view, CellHeight, view.Session()) @@ -363,13 +363,13 @@ func GetCellHeight(view View, subviewID string) []SizeUnit { } // GetGridRowGap returns the gap between GridLayout rows. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetGridRowGap(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetGridRowGap(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, GridRowGap, false) } // GetGridColumnGap returns the gap between GridLayout columns. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetGridColumnGap(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetGridColumnGap(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, GridColumnGap, false) } diff --git a/imageView.go b/imageView.go index f7d7e88..1302d61 100644 --- a/imageView.go +++ b/imageView.go @@ -244,7 +244,7 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde } } - if text := GetImageViewAltText(imageView, ""); text != "" { + if text := GetImageViewAltText(imageView); text != "" { buffer.WriteString(` alt="`) buffer.WriteString(textToJS(text)) buffer.WriteString(`"`) @@ -266,8 +266,8 @@ func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) { builder.add("object-fit", "none") } - vAlign := GetImageViewVerticalAlign(imageView, "") - hAlign := GetImageViewHorizontalAlign(imageView, "") + vAlign := GetImageViewVerticalAlign(imageView) + hAlign := GetImageViewHorizontalAlign(imageView) if vAlign != CenterAlign || hAlign != CenterAlign { var position string switch hAlign { @@ -323,10 +323,10 @@ func (imageView *imageViewData) CurrentSource() string { } // GetImageViewSource returns the image URL of an ImageView subview. -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetImageViewSource(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetImageViewSource(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -339,10 +339,10 @@ func GetImageViewSource(view View, subviewID string) string { } // GetImageViewAltText returns an alternative text description of an ImageView subview. -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetImageViewAltText(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetImageViewAltText(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -358,19 +358,19 @@ func GetImageViewAltText(view View, subviewID string) string { // GetImageViewFit returns how the content of a replaced ImageView subview: // NoneFit (0), ContainFit (1), CoverFit (2), FillFit (3), or ScaleDownFit (4). -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetImageViewFit(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetImageViewFit(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, Fit, NoneFit, false) } // GetImageViewVerticalAlign return the vertical align of an ImageView subview: TopAlign (0), BottomAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetImageViewVerticalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetImageViewVerticalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, ImageVerticalAlign, LeftAlign, false) } // GetImageViewHorizontalAlign return the vertical align of an ImageView subview: LeftAlign (0), RightAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetImageViewHorizontalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetImageViewHorizontalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, ImageHorizontalAlign, LeftAlign, false) } diff --git a/keyEvents.go b/keyEvents.go index 35a1789..5778290 100644 --- a/keyEvents.go +++ b/keyEvents.go @@ -227,9 +227,9 @@ func (view *viewData) removeKeyListener(tag string) { } } -func getEventListeners[V View, E any](view View, subviewID string, tag string) []func(V, E) { - if subviewID != "" { - view = ViewByID(view, subviewID) +func getEventListeners[V View, E any](view View, subviewID []string, tag string) []func(V, E) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.Get(tag); value != nil { @@ -243,14 +243,14 @@ func getEventListeners[V View, E any](view View, subviewID string, tag string) [ func keyEventsHtml(view View, buffer *strings.Builder) { for tag, js := range keyEvents { - if listeners := getEventListeners[View, KeyEvent](view, "", tag); len(listeners) > 0 { + if listeners := getEventListeners[View, KeyEvent](view, nil, tag); len(listeners) > 0 { buffer.WriteString(js.jsEvent + `="` + js.jsFunc + `(this, event)" `) } } } func handleKeyEvents(view View, tag string, data DataObject) { - listeners := getEventListeners[View, KeyEvent](view, "", tag) + listeners := getEventListeners[View, KeyEvent](view, nil, tag) if len(listeners) > 0 { var event KeyEvent event.init(data) @@ -262,13 +262,13 @@ func handleKeyEvents(view View, tag string, data DataObject) { } // GetKeyDownListeners returns the "key-down-event" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetKeyDownListeners(view View, subviewID string) []func(View, KeyEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetKeyDownListeners(view View, subviewID ...string) []func(View, KeyEvent) { return getEventListeners[View, KeyEvent](view, subviewID, KeyDownEvent) } // GetKeyUpListeners returns the "key-up-event" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetKeyUpListeners(view View, subviewID string) []func(View, KeyEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetKeyUpListeners(view View, subviewID ...string) []func(View, KeyEvent) { return getEventListeners[View, KeyEvent](view, subviewID, KeyUpEvent) } diff --git a/listAdapter.go b/listAdapter.go index fccd642..efa3d69 100644 --- a/listAdapter.go +++ b/listAdapter.go @@ -77,7 +77,7 @@ func (adapter *viewListAdapter) ListItem(index int, session Session) View { func (adapter *viewListAdapter) IsListItemEnabled(index int) bool { if index >= 0 && index < len(adapter.items) { - return !IsDisabled(adapter.items[index], "") + return !IsDisabled(adapter.items[index]) } return true } diff --git a/listLayout.go b/listLayout.go index d1d9cd2..872d762 100644 --- a/listLayout.go +++ b/listLayout.go @@ -74,7 +74,7 @@ func (listLayout *listLayoutData) Get(tag string) any { func (listLayout *listLayoutData) get(tag string) any { if tag == Gap { - if rowGap := GetListRowGap(listLayout, ""); rowGap.Equal(GetListColumnGap(listLayout, "")) { + if rowGap := GetListRowGap(listLayout); rowGap.Equal(GetListColumnGap(listLayout)) { return rowGap } return AutoSize() @@ -139,38 +139,24 @@ func (listLayout *listLayoutData) htmlSubviews(self View, buffer *strings.Builde // GetListVerticalAlign returns the vertical align of a ListLayout or ListView sibview: // TopAlign (0), BottomAlign (1), CenterAlign (2), or StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListVerticalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view == nil { - return LeftAlign - } - result, _ := enumProperty(view, VerticalAlign, view.Session(), 0) - return result +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListVerticalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, VerticalAlign, TopAlign, false) } // GetListHorizontalAlign returns the vertical align of a ListLayout or ListView subview: // LeftAlign (0), RightAlign (1), CenterAlign (2), or StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListHorizontalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view == nil { - return TopAlign - } - result, _ := enumProperty(view, HorizontalAlign, view.Session(), 0) - return result +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListHorizontalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, HorizontalAlign, LeftAlign, false) } // GetListOrientation returns the orientation of a ListLayout or ListView subview: // TopDownOrientation (0), StartToEndOrientation (1), BottomUpOrientation (2), or EndToStartOrientation (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListOrientation(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListOrientation(view View, subviewID ...string) int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -190,19 +176,19 @@ func GetListOrientation(view View, subviewID string) int { // GetListWrap returns the wrap type of a ListLayout or ListView subview: // ListWrapOff (0), ListWrapOn (1), or ListWrapReverse (2) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListWrap(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListWrap(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, ListWrap, ListWrapOff, false) } // GetListRowGap returns the gap between ListLayout or ListView rows. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListRowGap(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListRowGap(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, ListRowGap, false) } // GetListColumnGap returns the gap between ListLayout or ListView columns. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListColumnGap(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListColumnGap(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, ListColumnGap, false) } diff --git a/listView.go b/listView.go index f588bd1..30c0a49 100644 --- a/listView.go +++ b/listView.go @@ -158,7 +158,7 @@ func (listView *listViewData) remove(tag string) { } case Current: - current := GetCurrent(listView, "") + current := GetCurrent(listView) delete(listView.properties, tag) if listView.created { updateInnerHTML(listView.htmlID(), listView.session) @@ -264,11 +264,11 @@ func (listView *listViewData) set(tag string, value any) bool { } case Current: - oldCurrent := GetCurrent(listView, "") + oldCurrent := GetCurrent(listView) if !listView.setIntProperty(Current, value) { return false } - current := GetCurrent(listView, "") + current := GetCurrent(listView) if oldCurrent == current { return true } @@ -317,7 +317,7 @@ func (listView *listViewData) Get(tag string) any { func (listView *listViewData) get(tag string) any { switch tag { case Gap: - if rowGap := GetListRowGap(listView, ""); rowGap.Equal(GetListColumnGap(listView, "")) { + if rowGap := GetListRowGap(listView); rowGap.Equal(GetListColumnGap(listView)) { return rowGap } return AutoSize() @@ -462,7 +462,7 @@ func (listView *listViewData) setChecked(value any) bool { } } - switch GetListViewCheckbox(listView, "") { + switch GetListViewCheckbox(listView) { case SingleCheckbox: count := len(checked) if count > 1 { @@ -546,14 +546,14 @@ func (listView *listViewData) getItemFrames() []Frame { func (listView *listViewData) itemAlign(self View, buffer *strings.Builder) { values := enumProperties[ItemHorizontalAlign].cssValues - if hAlign := GetListItemHorizontalAlign(listView, ""); hAlign >= 0 && hAlign < len(values) { + if hAlign := GetListItemHorizontalAlign(listView); hAlign >= 0 && hAlign < len(values) { buffer.WriteString(" justify-items: ") buffer.WriteString(values[hAlign]) buffer.WriteRune(';') } values = enumProperties[ItemVerticalAlign].cssValues - if vAlign := GetListItemVerticalAlign(listView, ""); vAlign >= 0 && vAlign < len(values) { + if vAlign := GetListItemVerticalAlign(listView); vAlign >= 0 && vAlign < len(values) { buffer.WriteString(" align-items: ") buffer.WriteString(values[vAlign]) buffer.WriteRune(';') @@ -561,13 +561,13 @@ func (listView *listViewData) itemAlign(self View, buffer *strings.Builder) { } func (listView *listViewData) itemSize(self View, buffer *strings.Builder) { - if itemWidth := GetListItemWidth(listView, ""); itemWidth.Type != Auto { + if itemWidth := GetListItemWidth(listView); itemWidth.Type != Auto { buffer.WriteString(` min-width: `) buffer.WriteString(itemWidth.cssString("")) buffer.WriteRune(';') } - if itemHeight := GetListItemHeight(listView, ""); itemHeight.Type != Auto { + if itemHeight := GetListItemHeight(listView); itemHeight.Type != Auto { buffer.WriteString(` min-height: `) buffer.WriteString(itemHeight.cssString("")) buffer.WriteRune(';') @@ -719,14 +719,14 @@ func (listView *listViewData) checkboxSubviews(self View, buffer *strings.Builde count := listView.adapter.ListSize() listViewID := listView.htmlID() - hCheckboxAlign := GetListViewCheckboxHorizontalAlign(listView, "") - vCheckboxAlign := GetListViewCheckboxVerticalAlign(listView, "") + hCheckboxAlign := GetListViewCheckboxHorizontalAlign(listView) + vCheckboxAlign := GetListViewCheckboxVerticalAlign(listView) itemDiv := listView.checkboxItemDiv(self, checkbox, hCheckboxAlign, vCheckboxAlign) onDiv, offDiv, contentDiv := listView.getDivs(self, checkbox, hCheckboxAlign, vCheckboxAlign) - current := GetCurrent(listView, "") - checkedItems := GetListViewCheckedItems(listView, "") + current := GetCurrent(listView) + checkedItems := GetListViewCheckedItems(listView) for i := 0; i < count; i++ { buffer.WriteString(`
= 0 && current < listView.adapter.ListSize() { buffer.WriteString(` data-current="`) buffer.WriteString(listView.htmlID()) @@ -871,8 +871,8 @@ func (listView *listViewData) htmlProperties(self View, buffer *strings.Builder) func (listView *listViewData) cssStyle(self View, builder cssBuilder) { listView.viewData.cssStyle(self, builder) - if GetListWrap(listView, "") != WrapOff { - switch GetListOrientation(listView, "") { + if GetListWrap(listView) != WrapOff { + switch GetListOrientation(listView) { case TopDownOrientation, BottomUpOrientation: builder.add(`max-height`, `100%`) default: @@ -894,20 +894,20 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) { buffer.WriteString(`
`) - checkbox := GetListViewCheckbox(listView, "") + checkbox := GetListViewCheckbox(listView) if checkbox == NoneCheckbox { listView.noneCheckboxSubviews(self, buffer) } else { @@ -1056,9 +1056,9 @@ func (listView *listViewData) handleCommand(self View, command string, data Data } func (listView *listViewData) onItemClick() { - current := GetCurrent(listView, "") - if current >= 0 && !IsDisabled(listView, "") { - checkbox := GetListViewCheckbox(listView, "") + current := GetCurrent(listView) + if current >= 0 && !IsDisabled(listView) { + checkbox := GetListViewCheckbox(listView) m: switch checkbox { case SingleCheckbox: @@ -1117,117 +1117,67 @@ func (listView *listViewData) onItemResize(self View, index string, x, y, width, } // GetVerticalAlign return the vertical align of a list: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetVerticalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetVerticalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, VerticalAlign, TopAlign, false) } // GetHorizontalAlign return the vertical align of a list/checkbox: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetHorizontalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetHorizontalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, HorizontalAlign, LeftAlign, false) } // GetListItemClickedListeners returns a ListItemClickedListener of the ListView. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemClickedListeners(view View, subviewID string) []func(ListView, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if value := view.Get(ListItemClickedEvent); value != nil { - if result, ok := value.([]func(ListView, int)); ok { - return result - } - } - } - return []func(ListView, int){} +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemClickedListeners(view View, subviewID ...string) []func(ListView, int) { + return getEventListeners[ListView, int](view, subviewID, ListItemClickedEvent) } // GetListItemSelectedListeners returns a ListItemSelectedListener of the ListView. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemSelectedListeners(view View, subviewID string) []func(ListView, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if value := view.Get(ListItemSelectedEvent); value != nil { - if result, ok := value.([]func(ListView, int)); ok { - return result - } - } - } - return []func(ListView, int){} +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemSelectedListeners(view View, subviewID ...string) []func(ListView, int) { + return getEventListeners[ListView, int](view, subviewID, ListItemSelectedEvent) } // GetListItemCheckedListeners returns a ListItemCheckedListener of the ListView. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemCheckedListeners(view View, subviewID string) []func(ListView, []int) { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if value := view.Get(ListItemCheckedEvent); value != nil { - if result, ok := value.([]func(ListView, []int)); ok { - return result - } - } - } - return []func(ListView, []int){} +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemCheckedListeners(view View, subviewID ...string) []func(ListView, []int) { + return getEventListeners[ListView, []int](view, subviewID, ListItemCheckedEvent) } // GetListItemWidth returns the width of a ListView item. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemWidth(view View, subviewID string) SizeUnit { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - result, _ := sizeProperty(view, ItemWidth, view.Session()) - return result - } - return AutoSize() +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemWidth(view View, subviewID ...string) SizeUnit { + return sizeStyledProperty(view, subviewID, ItemWidth, false) } // GetListItemHeight returns the height of a ListView item. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemHeight(view View, subviewID string) SizeUnit { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - result, _ := sizeProperty(view, ItemHeight, view.Session()) - return result - } - return AutoSize() +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemHeight(view View, subviewID ...string) SizeUnit { + return sizeStyledProperty(view, subviewID, ItemHeight, false) } // GetListViewCheckbox returns the ListView checkbox type: NoneCheckbox (0), SingleCheckbox (1), or MultipleCheckbox (2). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListViewCheckbox(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - result, _ := enumProperty(view, ItemCheckbox, view.Session(), 0) - return result - } - return 0 +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListViewCheckbox(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, ItemCheckbox, 0, false) } // GetListViewCheckedItems returns the array of ListView checked items. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListViewCheckedItems(view View, subviewID string) []int { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListViewCheckedItems(view View, subviewID ...string) []int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if listView, ok := view.(ListView); ok { checkedItems := listView.getCheckedItems() - switch GetListViewCheckbox(view, "") { + switch GetListViewCheckbox(view) { case NoneCheckbox: return []int{} @@ -1256,66 +1206,34 @@ func IsListViewCheckedItem(view View, subviewID string, index int) bool { // GetListViewCheckboxVerticalAlign returns the vertical align of the ListView checkbox: // TopAlign (0), BottomAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListViewCheckboxVerticalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if align, ok := enumProperty(view, CheckboxVerticalAlign, view.Session(), TopAlign); ok { - return align - } - } - return TopAlign +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListViewCheckboxVerticalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, CheckboxVerticalAlign, TopAlign, false) } // GetListViewCheckboxHorizontalAlign returns the horizontal align of the ListView checkbox: // LeftAlign (0), RightAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListViewCheckboxHorizontalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if align, ok := enumProperty(view, CheckboxHorizontalAlign, view.Session(), LeftAlign); ok { - return align - } - } - return LeftAlign +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListViewCheckboxHorizontalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, CheckboxHorizontalAlign, LeftAlign, false) } // GetListItemVerticalAlign returns the vertical align of the ListView item content: // TopAlign (0), BottomAlign (1), CenterAlign (2) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemVerticalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if align, ok := enumProperty(view, ItemVerticalAlign, view.Session(), TopAlign); ok { - return align - } - } - return TopAlign +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemVerticalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, ItemVerticalAlign, TopAlign, false) } // ItemHorizontalAlign returns the horizontal align of the ListView item content: // LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListItemHorizontalAlign(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if align, ok := enumProperty(view, ItemHorizontalAlign, view.Session(), LeftAlign); ok { - return align - } - } - return LeftAlign +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListItemHorizontalAlign(view View, subviewID ...string) int { + return enumStyledProperty(view, subviewID, ItemHorizontalAlign, LeftAlign, false) } // GetListItemFrame - returns the location and size of the ListView item in pixels. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. func GetListItemFrame(view View, subviewID string, index int) Frame { if subviewID != "" { view = ViewByID(view, subviewID) @@ -1332,10 +1250,10 @@ func GetListItemFrame(view View, subviewID string, index int) Frame { } // GetListViewAdapter - returns the ListView adapter. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetListViewAdapter(view View, subviewID string) ListAdapter { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetListViewAdapter(view View, subviewID ...string) ListAdapter { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.Get(Items); value != nil { @@ -1348,11 +1266,12 @@ func GetListViewAdapter(view View, subviewID string) ListAdapter { } // ReloadListViewData updates ListView content -// If the second argument (subviewID) is "" then content the first argument (view) is updated. -func ReloadListViewData(view View, subviewID string) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated. +func ReloadListViewData(view View, subviewID ...string) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if listView, ok := view.(ListView); ok { listView.ReloadListViewData() diff --git a/mouseEvents.go b/mouseEvents.go index daa547e..8370279 100644 --- a/mouseEvents.go +++ b/mouseEvents.go @@ -224,7 +224,7 @@ func (event *MouseEvent) init(data DataObject) { } func handleMouseEvents(view View, tag string, data DataObject) { - listeners := getEventListeners[View, MouseEvent](view, "", tag) + listeners := getEventListeners[View, MouseEvent](view, nil, tag) if len(listeners) > 0 { var event MouseEvent event.init(data) @@ -236,50 +236,50 @@ func handleMouseEvents(view View, tag string, data DataObject) { } // GetClickListeners returns the "click-event" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetClickListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetClickListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, ClickEvent) } // GetDoubleClickListeners returns the "double-click-event" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetDoubleClickListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetDoubleClickListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, DoubleClickEvent) } // GetContextMenuListeners returns the "context-menu" listener list. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetContextMenuListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetContextMenuListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, ContextMenuEvent) } // GetMouseDownListeners returns the "mouse-down" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetMouseDownListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetMouseDownListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, MouseDown) } // GetMouseUpListeners returns the "mouse-up" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetMouseUpListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetMouseUpListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, MouseUp) } // GetMouseMoveListeners returns the "mouse-move" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetMouseMoveListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetMouseMoveListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, MouseMove) } // GetMouseOverListeners returns the "mouse-over" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetMouseOverListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetMouseOverListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, MouseOver) } // GetMouseOutListeners returns the "mouse-out" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetMouseOutListeners(view View, subviewID string) []func(View, MouseEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetMouseOutListeners(view View, subviewID ...string) []func(View, MouseEvent) { return getEventListeners[View, MouseEvent](view, subviewID, MouseOut) } diff --git a/numberPicker.go b/numberPicker.go index 258ffef..e405115 100644 --- a/numberPicker.go +++ b/numberPicker.go @@ -111,8 +111,8 @@ func (picker *numberPickerData) set(tag string, value any) bool { return true case NumberPickerValue: - oldValue := GetNumberPickerValue(picker, "") - min, max := GetNumberPickerMinMax(picker, "") + oldValue := GetNumberPickerValue(picker) + min, max := GetNumberPickerMinMax(picker) if picker.setFloatProperty(NumberPickerValue, value, min, max) { if f, ok := floatProperty(picker, NumberPickerValue, picker.Session(), min); ok && f != oldValue { newValue, _ := floatTextProperty(picker, NumberPickerValue, picker.Session(), min) @@ -140,29 +140,29 @@ func (picker *numberPickerData) propertyChanged(tag string) { if picker.created { switch tag { case NumberPickerType: - if GetNumberPickerType(picker, "") == NumberSlider { + if GetNumberPickerType(picker) == NumberSlider { updateProperty(picker.htmlID(), "type", "range", picker.session) } else { updateProperty(picker.htmlID(), "type", "number", picker.session) } case NumberPickerMin: - min, _ := GetNumberPickerMinMax(picker, "") + min, _ := GetNumberPickerMinMax(picker) updateProperty(picker.htmlID(), Min, strconv.FormatFloat(min, 'f', -1, 32), picker.session) case NumberPickerMax: - _, max := GetNumberPickerMinMax(picker, "") + _, max := GetNumberPickerMinMax(picker) updateProperty(picker.htmlID(), Max, strconv.FormatFloat(max, 'f', -1, 32), picker.session) case NumberPickerStep: - if step := GetNumberPickerStep(picker, ""); step > 0 { + if step := GetNumberPickerStep(picker); step > 0 { updateProperty(picker.htmlID(), Step, strconv.FormatFloat(step, 'f', -1, 32), picker.session) } else { updateProperty(picker.htmlID(), Step, "any", picker.session) } case NumberPickerValue: - value := GetNumberPickerValue(picker, "") + value := GetNumberPickerValue(picker) picker.session.runScript(fmt.Sprintf(`setInputValue('%s', '%f')`, picker.htmlID(), value)) for _, listener := range picker.numberChangedListeners { listener(picker, value) @@ -192,13 +192,13 @@ func (picker *numberPickerData) htmlTag() string { func (picker *numberPickerData) htmlProperties(self View, buffer *strings.Builder) { picker.viewData.htmlProperties(self, buffer) - if GetNumberPickerType(picker, "") == NumberSlider { + if GetNumberPickerType(picker) == NumberSlider { buffer.WriteString(` type="range"`) } else { buffer.WriteString(` type="number"`) } - min, max := GetNumberPickerMinMax(picker, "") + min, max := GetNumberPickerMinMax(picker) if min != math.Inf(-1) { buffer.WriteString(` min="`) buffer.WriteString(strconv.FormatFloat(min, 'f', -1, 64)) @@ -211,7 +211,7 @@ func (picker *numberPickerData) htmlProperties(self View, buffer *strings.Builde buffer.WriteByte('"') } - step := GetNumberPickerStep(picker, "") + step := GetNumberPickerStep(picker) if step != 0 { buffer.WriteString(` step="`) buffer.WriteString(strconv.FormatFloat(step, 'f', -1, 64)) @@ -221,14 +221,14 @@ func (picker *numberPickerData) htmlProperties(self View, buffer *strings.Builde } buffer.WriteString(` value="`) - buffer.WriteString(strconv.FormatFloat(GetNumberPickerValue(picker, ""), 'f', -1, 64)) + buffer.WriteString(strconv.FormatFloat(GetNumberPickerValue(picker), 'f', -1, 64)) buffer.WriteByte('"') buffer.WriteString(` oninput="editViewInputEvent(this)"`) } func (picker *numberPickerData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } picker.viewData.htmlDisabledProperties(self, buffer) @@ -239,7 +239,7 @@ func (picker *numberPickerData) handleCommand(self View, command string, data Da case "textChanged": if text, ok := data.PropertyValue("text"); ok { if value, err := strconv.ParseFloat(text, 32); err == nil { - oldValue := GetNumberPickerValue(picker, "") + oldValue := GetNumberPickerValue(picker) picker.properties[NumberPickerValue] = text if value != oldValue { for _, listener := range picker.numberChangedListeners { @@ -257,16 +257,23 @@ func (picker *numberPickerData) handleCommand(self View, command string, data Da // GetNumberPickerType returns the type of NumberPicker subview. Valid values: // NumberEditor (0) - NumberPicker is presented by editor (default type); // NumberSlider (1) - NumberPicker is presented by slider. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetNumberPickerType(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetNumberPickerType(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, NumberPickerType, NumberEditor, false) } // GetNumberPickerMinMax returns the min and max value of NumberPicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetNumberPickerMinMax(view View, subviewID string) (float64, float64) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64) { + var pickerType int + if len(subviewID) > 0 && subviewID[0] != "" { + pickerType = GetNumberPickerType(view, subviewID[0]) + } else { + pickerType = GetNumberPickerType(view) + } + var defMin, defMax float64 - if GetNumberPickerType(view, subviewID) == NumberSlider { + if pickerType == NumberSlider { defMin = 0 defMax = 1 } else { @@ -284,9 +291,15 @@ func GetNumberPickerMinMax(view View, subviewID string) (float64, float64) { } // GetNumberPickerStep returns the value changing step of NumberPicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetNumberPickerStep(view View, subviewID string) float64 { - _, max := GetNumberPickerMinMax(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetNumberPickerStep(view View, subviewID ...string) float64 { + var max float64 + if len(subviewID) > 0 && subviewID[0] != "" { + _, max = GetNumberPickerMinMax(view, subviewID[0]) + } else { + _, max = GetNumberPickerMinMax(view) + } + result := floatStyledProperty(view, subviewID, NumberPickerStep, 0) if result > max { return max @@ -295,16 +308,22 @@ func GetNumberPickerStep(view View, subviewID string) float64 { } // GetNumberPickerValue returns the value of NumberPicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetNumberPickerValue(view View, subviewID string) float64 { - min, _ := GetNumberPickerMinMax(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetNumberPickerValue(view View, subviewID ...string) float64 { + var min float64 + if len(subviewID) > 0 && subviewID[0] != "" { + min, _ = GetNumberPickerMinMax(view, subviewID[0]) + } else { + min, _ = GetNumberPickerMinMax(view) + } + result := floatStyledProperty(view, subviewID, NumberPickerValue, min) return result } // GetNumberChangedListeners returns the NumberChangedListener list of an NumberPicker subview. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetNumberChangedListeners(view View, subviewID string) []func(NumberPicker, float64) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetNumberChangedListeners(view View, subviewID ...string) []func(NumberPicker, float64) { return getEventListeners[NumberPicker, float64](view, subviewID, NumberChangedEvent) } diff --git a/pointerEvents.go b/pointerEvents.go index d7cd051..c565079 100644 --- a/pointerEvents.go +++ b/pointerEvents.go @@ -152,7 +152,7 @@ func (event *PointerEvent) init(data DataObject) { } func handlePointerEvents(view View, tag string, data DataObject) { - listeners := getEventListeners[View, PointerEvent](view, "", tag) + listeners := getEventListeners[View, PointerEvent](view, nil, tag) if len(listeners) == 0 { return } @@ -166,37 +166,37 @@ func handlePointerEvents(view View, tag string, data DataObject) { } // GetPointerDownListeners returns the "pointer-down" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerDownListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerDownListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerDown) } // GetPointerUpListeners returns the "pointer-up" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerUpListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerUpListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerUp) } // GetPointerMoveListeners returns the "pointer-move" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerMoveListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerMoveListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerMove) } // GetPointerCancelListeners returns the "pointer-cancel" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerCancelListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerCancelListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerCancel) } // GetPointerOverListeners returns the "pointer-over" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerOverListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerOverListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerOver) } // GetPointerOutListeners returns the "pointer-out" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPointerOutListeners(view View, subviewID string) []func(View, PointerEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPointerOutListeners(view View, subviewID ...string) []func(View, PointerEvent) { return getEventListeners[View, PointerEvent](view, subviewID, PointerOut) } diff --git a/popup.go b/popup.go index 32f2da6..957318d 100644 --- a/popup.go +++ b/popup.go @@ -115,7 +115,7 @@ type popupArrow struct { func (arrow *popupArrow) fixOff(popupView View) { if arrow.align == CenterAlign && arrow.off.Type == Auto { - r := GetRadius(popupView, "") + r := GetRadius(popupView) switch arrow.location { case TopArrow: switch arrow.align { @@ -176,13 +176,13 @@ func (arrow *popupArrow) createView(popupView View) View { arrow.width = defaultSize("ruiArrowWidth", Px(16)) } - params := Params{BackgroundColor: GetBackgroundColor(popupView, "")} + params := Params{BackgroundColor: GetBackgroundColor(popupView)} - if shadow := GetViewShadows(popupView, ""); shadow != nil { + if shadow := GetViewShadows(popupView); shadow != nil { params[Shadow] = shadow } - if filter := GetBackdropFilter(popupView, ""); filter != nil { + if filter := GetBackdropFilter(popupView); filter != nil { params[BackdropFilter] = filter } diff --git a/progressBar.go b/progressBar.go index ab7bb32..78767de 100644 --- a/progressBar.go +++ b/progressBar.go @@ -65,10 +65,10 @@ func (progress *progressBarData) propertyChanged(tag string) { if progress.created { switch tag { case ProgressBarMax: - updateProperty(progress.htmlID(), Max, strconv.FormatFloat(GetProgressBarMax(progress, ""), 'f', -1, 32), progress.session) + updateProperty(progress.htmlID(), Max, strconv.FormatFloat(GetProgressBarMax(progress), 'f', -1, 32), progress.session) case ProgressBarValue: - updateProperty(progress.htmlID(), Value, strconv.FormatFloat(GetProgressBarValue(progress, ""), 'f', -1, 32), progress.session) + updateProperty(progress.htmlID(), Value, strconv.FormatFloat(GetProgressBarValue(progress), 'f', -1, 32), progress.session) } } } @@ -97,22 +97,22 @@ func (progress *progressBarData) htmlProperties(self View, buffer *strings.Build progress.viewData.htmlProperties(self, buffer) buffer.WriteString(` max="`) - buffer.WriteString(strconv.FormatFloat(GetProgressBarMax(progress, ""), 'f', -1, 64)) + buffer.WriteString(strconv.FormatFloat(GetProgressBarMax(progress), 'f', -1, 64)) buffer.WriteByte('"') buffer.WriteString(` value="`) - buffer.WriteString(strconv.FormatFloat(GetProgressBarValue(progress, ""), 'f', -1, 64)) + buffer.WriteString(strconv.FormatFloat(GetProgressBarValue(progress), 'f', -1, 64)) buffer.WriteByte('"') } // GetProgressBarMax returns the max value of ProgressBar subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetProgressBarMax(view View, subviewID string) float64 { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetProgressBarMax(view View, subviewID ...string) float64 { return floatStyledProperty(view, subviewID, ProgressBarMax, 1) } // GetProgressBarValue returns the value of ProgressBar subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetProgressBarValue(view View, subviewID string) float64 { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetProgressBarValue(view View, subviewID ...string) float64 { return floatStyledProperty(view, subviewID, ProgressBarValue, 0) } diff --git a/resizeEvent.go b/resizeEvent.go index 8d58edb..ee53b62 100644 --- a/resizeEvent.go +++ b/resizeEvent.go @@ -3,9 +3,12 @@ package rui // ResizeEvent is the constant for "resize-event" property tag. // The "resize-event" is fired when the view changes its size. // The main listener format: -// func(View, Frame). +// +// func(View, Frame). +// // The additional listener formats: -// func(Frame), func(View), and func(). +// +// func(Frame), func(View), and func(). const ResizeEvent = "resize-event" func (view *viewData) onResize(self View, x, y, width, height float64) { @@ -13,7 +16,7 @@ func (view *viewData) onResize(self View, x, y, width, height float64) { view.frame.Top = y view.frame.Width = width view.frame.Height = height - for _, listener := range GetResizeListeners(view, "") { + for _, listener := range GetResizeListeners(view) { listener(self, view.frame) } } @@ -62,10 +65,10 @@ func (view *viewData) Frame() Frame { } // GetViewFrame returns the size and location of view's viewport. -// If the second argument (subviewID) is "" then the value of the first argument (view) is returned -func GetViewFrame(view View, subviewID string) Frame { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then the value of the first argument (view) is returned +func GetViewFrame(view View, subviewID ...string) Frame { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return Frame{} @@ -74,7 +77,7 @@ func GetViewFrame(view View, subviewID string) Frame { } // GetResizeListeners returns the list of "resize-event" listeners. If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then the listeners list of the first argument (view) is returned -func GetResizeListeners(view View, subviewID string) []func(View, Frame) { +// If the second argument (subviewID) is not specified or it is "" then the listeners list of the first argument (view) is returned +func GetResizeListeners(view View, subviewID ...string) []func(View, Frame) { return getEventListeners[View, Frame](view, subviewID, ResizeEvent) } diff --git a/scrollEvent.go b/scrollEvent.go index ac5a185..7afa29f 100644 --- a/scrollEvent.go +++ b/scrollEvent.go @@ -5,9 +5,12 @@ import "fmt" // ScrollEvent is the constant for "scroll-event" property tag. // The "scroll-event" is fired when the content of the view is scrolled. // The main listener format: -// func(View, Frame). +// +// func(View, Frame). +// // The additional listener formats: -// func(Frame), func(View), and func(). +// +// func(Frame), func(View), and func(). const ScrollEvent = "scroll-event" func (view *viewData) onScroll(self View, x, y, width, height float64) { @@ -15,7 +18,7 @@ func (view *viewData) onScroll(self View, x, y, width, height float64) { view.scroll.Top = y view.scroll.Width = width view.scroll.Height = height - for _, listener := range GetScrollListeners(view, "") { + for _, listener := range GetScrollListeners(view) { listener(self, view.scroll) } } @@ -32,10 +35,10 @@ func (view *viewData) setScroll(x, y, width, height float64) { } // GetViewScroll returns ... -// If the second argument (subviewID) is "" then a value of the first argument (view) is returned -func GetViewScroll(view View, subviewID string) Frame { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned +func GetViewScroll(view View, subviewID ...string) Frame { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return Frame{} @@ -44,8 +47,8 @@ func GetViewScroll(view View, subviewID string) Frame { } // GetScrollListeners returns the list of "scroll-event" listeners. If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then the listeners list of the first argument (view) is returned -func GetScrollListeners(view View, subviewID string) []func(View, Frame) { +// If the second argument (subviewID) is not specified or it is "" then the listeners list of the first argument (view) is returned +func GetScrollListeners(view View, subviewID ...string) []func(View, Frame) { return getEventListeners[View, Frame](view, subviewID, ResizeEvent) } @@ -61,10 +64,10 @@ func ScrollViewTo(view View, subviewID string, x, y float64) { } // ScrollViewToEnd scrolls the view's content to the start of view. -// If the second argument (subviewID) is "" then the first argument (view) is used -func ScrollViewToStart(view View, subviewID string) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used +func ScrollViewToStart(view View, subviewID ...string) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { view.Session().runScript(`scrollToStart("` + view.htmlID() + `")`) @@ -72,10 +75,10 @@ func ScrollViewToStart(view View, subviewID string) { } // ScrollViewToEnd scrolls the view's content to the end of view. -// If the second argument (subviewID) is "" then the first argument (view) is used -func ScrollViewToEnd(view View, subviewID string) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then the first argument (view) is used +func ScrollViewToEnd(view View, subviewID ...string) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { view.Session().runScript(`scrollToEnd("` + view.htmlID() + `")`) diff --git a/tableView.go b/tableView.go index 82870e5..eead271 100644 --- a/tableView.go +++ b/tableView.go @@ -290,7 +290,7 @@ func (table *tableViewData) normalizeTag(tag string) string { } func (table *tableViewData) Focusable() bool { - return GetTableSelectionMode(table, "") != NoneSelection + return GetTableSelectionMode(table) != NoneSelection } func (table *tableViewData) Get(tag string) any { @@ -602,7 +602,7 @@ func (table *tableViewData) propertyChanged(tag string) { htmlID := table.htmlID() session := table.Session() - switch GetTableSelectionMode(table, "") { + switch GetTableSelectionMode(table) { case CellSelection: updateProperty(htmlID, "tabindex", "0", session) updateProperty(htmlID, "onfocus", "tableViewFocusEvent(this, event)", session) @@ -757,7 +757,7 @@ func (table *tableViewData) htmlProperties(self View, buffer *strings.Builder) { buffer.WriteRune('"') } - if selectionMode := GetTableSelectionMode(table, ""); selectionMode != NoneSelection { + if selectionMode := GetTableSelectionMode(table); selectionMode != NoneSelection { buffer.WriteString(` onfocus="tableViewFocusEvent(this, event)" onblur="tableViewBlurEvent(this, event)" data-focusitemstyle="`) buffer.WriteString(table.currentStyle()) buffer.WriteString(`" data-bluritemstyle="`) @@ -831,7 +831,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) { view.Init(session) ignorCells := []struct{ row, column int }{} - selectionMode := GetTableSelectionMode(table, "") + selectionMode := GetTableSelectionMode(table) var allowCellSelection TableAllowCellSelection = nil if allow, ok := adapter.(TableAllowCellSelection); ok { @@ -854,7 +854,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) { } vAlignCss := enumProperties[TableVerticalAlign].cssValues - vAlignValue := GetTableVerticalAlign(table, "") + vAlignValue := GetTableVerticalAlign(table) if vAlignValue < 0 || vAlignValue >= len(vAlignCss) { vAlignValue = 0 } @@ -1109,8 +1109,8 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) { buffer.WriteString("") } - headHeight := GetTableHeadHeight(table, "") - footHeight := GetTableFootHeight(table, "") + headHeight := GetTableHeadHeight(table) + footHeight := GetTableFootHeight(table) cellBorder := table.getCellBorder() cellPadding := table.boundsProperty(CellPadding) if cellPadding == nil { diff --git a/tableViewUtils.go b/tableViewUtils.go index 31be746..3c2e829 100644 --- a/tableViewUtils.go +++ b/tableViewUtils.go @@ -24,10 +24,10 @@ func (cell *tableCellView) cssStyle(self View, builder cssBuilder) { } // GetTableContent returns a TableAdapter which defines the TableView content. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableContent(view View, subviewID string) TableAdapter { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableContent(view View, subviewID ...string) TableAdapter { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -40,10 +40,10 @@ func GetTableContent(view View, subviewID string) TableAdapter { } // GetTableRowStyle returns a TableRowStyle which defines styles of TableView rows. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableRowStyle(view View, subviewID string) TableRowStyle { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableRowStyle(view View, subviewID ...string) TableRowStyle { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -56,10 +56,10 @@ func GetTableRowStyle(view View, subviewID string) TableRowStyle { } // GetTableColumnStyle returns a TableColumnStyle which defines styles of TableView columns. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableColumnStyle(view View, subviewID string) TableColumnStyle { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -72,10 +72,10 @@ func GetTableColumnStyle(view View, subviewID string) TableColumnStyle { } // GetTableCellStyle returns a TableCellStyle which defines styles of TableView cells. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableCellStyle(view View, subviewID string) TableCellStyle { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableCellStyle(view View, subviewID ...string) TableCellStyle { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -89,27 +89,27 @@ func GetTableCellStyle(view View, subviewID string) TableCellStyle { // GetTableSelectionMode returns the mode of the TableView elements selection. // Valid values are NoneSelection (0), CellSelection (1), and RowSelection (2). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableSelectionMode(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableSelectionMode(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, SelectionMode, NoneSelection, false) } // GetTableVerticalAlign returns a vertical align in a TavleView cell. Returns one of next values: // TopAlign (0), BottomAlign (1), CenterAlign (2), and BaselineAlign (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableVerticalAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableVerticalAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TableVerticalAlign, TopAlign, false) } // GetTableHeadHeight returns the number of rows in the table header. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableHeadHeight(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableHeadHeight(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, HeadHeight, 0) } // GetTableFootHeight returns the number of rows in the table footer. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableFootHeight(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableFootHeight(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, FootHeight, 0) } @@ -117,14 +117,14 @@ func GetTableFootHeight(view View, subviewID string) int { // If there is no selected cell/row or the selection mode is NoneSelection (0), // then a value of the row and column index less than 0 is returned. // If the selection mode is RowSelection (2) then the returned column index is less than 0. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableCurrent(view View, subviewID string) CellIndex { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableCurrent(view View, subviewID ...string) CellIndex { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { - if selectionMode := GetTableSelectionMode(view, ""); selectionMode != NoneSelection { + if selectionMode := GetTableSelectionMode(view); selectionMode != NoneSelection { if tableView, ok := view.(TableView); ok { return tableView.getCurrent() } @@ -135,10 +135,10 @@ func GetTableCurrent(view View, subviewID string) CellIndex { // GetTableCellClickedListeners returns listeners of event which occurs when the user clicks on a table cell. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableCellClickedListeners(view View, subviewID string) []func(TableView, int, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableCellClickedListeners(view View, subviewID ...string) []func(TableView, int, int) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.Get(TableCellClickedEvent); value != nil { @@ -152,10 +152,10 @@ func GetTableCellClickedListeners(view View, subviewID string) []func(TableView, // GetTableCellSelectedListeners returns listeners of event which occurs when a table cell becomes selected. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableCellSelectedListeners(view View, subviewID string) []func(TableView, int, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableCellSelectedListeners(view View, subviewID ...string) []func(TableView, int, int) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value := view.Get(TableCellSelectedEvent); value != nil { @@ -169,43 +169,23 @@ func GetTableCellSelectedListeners(view View, subviewID string) []func(TableView // GetTableRowClickedListeners returns listeners of event which occurs when the user clicks on a table row. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableRowClickedListeners(view View, subviewID string) []func(TableView, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if value := view.Get(TableRowClickedEvent); value != nil { - if result, ok := value.([]func(TableView, int)); ok { - return result - } - } - } - return []func(TableView, int){} +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableRowClickedListeners(view View, subviewID ...string) []func(TableView, int) { + return getEventListeners[TableView, int](view, subviewID, TableRowClickedEvent) } // GetTableRowSelectedListeners returns listeners of event which occurs when a table row becomes selected. // If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTableRowSelectedListeners(view View, subviewID string) []func(TableView, int) { - if subviewID != "" { - view = ViewByID(view, subviewID) - } - if view != nil { - if value := view.Get(TableRowSelectedEvent); value != nil { - if result, ok := value.([]func(TableView, int)); ok { - return result - } - } - } - return []func(TableView, int){} +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTableRowSelectedListeners(view View, subviewID ...string) []func(TableView, int) { + return getEventListeners[TableView, int](view, subviewID, TableRowSelectedEvent) } // ReloadTableViewData updates TableView -func ReloadTableViewData(view View, subviewID string) bool { +func ReloadTableViewData(view View, subviewID ...string) bool { var tableView TableView - if subviewID != "" { - if tableView = TableViewByID(view, subviewID); tableView == nil { + if len(subviewID) > 0 && subviewID[0] != "" { + if tableView = TableViewByID(view, subviewID[0]); tableView == nil { return false } } else { diff --git a/tabsLayout.go b/tabsLayout.go index 05647d4..94c3d0e 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -523,7 +523,7 @@ func (tabsLayout *tabsLayoutData) ListItem(index int, session Session) View { if !ok || title == "" { title = "No title" } - if !GetNotTranslate(tabsLayout, "") { + if !GetNotTranslate(tabsLayout) { title, _ = tabsLayout.Session().GetString(title) } @@ -723,7 +723,7 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde inactiveStyle := tabsLayout.inactiveTabStyle() activeStyle := tabsLayout.activeTabStyle() - notTranslate := GetNotTranslate(tabsLayout, "") + notTranslate := GetNotTranslate(tabsLayout) closeButton, _ := boolProperty(tabsLayout, TabCloseButton, tabsLayout.session) var tabStyle, titleDiv string diff --git a/textView.go b/textView.go index 9899cbb..e38a9f9 100644 --- a/textView.go +++ b/textView.go @@ -155,7 +155,7 @@ func textToJS(text string) string { func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) { if value := textView.getRaw(Text); value != nil { if text, ok := value.(string); ok { - if !GetNotTranslate(textView, "") { + if !GetNotTranslate(textView) { text, _ = textView.session.GetString(text) } buffer.WriteString(textToJS(text)) @@ -165,7 +165,7 @@ func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) { // GetTextOverflow returns a value of the "text-overflow" property: // TextOverflowClip (0) or TextOverflowEllipsis (1). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextOverflow(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextOverflow(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TextOverflow, SingleLineText, false) } diff --git a/timePicker.go b/timePicker.go index ef6dd10..f9cd8aa 100644 --- a/timePicker.go +++ b/timePicker.go @@ -96,7 +96,7 @@ func (picker *timePickerData) remove(tag string) { case TimePickerValue: if _, ok := picker.properties[TimePickerValue]; ok { delete(picker.properties, TimePickerValue) - time := GetTimePickerValue(picker, "") + time := GetTimePickerValue(picker) if picker.created { picker.session.runScript(fmt.Sprintf(`setInputValue('%s', '%s')`, picker.htmlID(), time.Format(timeFormat))) } @@ -192,9 +192,9 @@ func (picker *timePickerData) set(tag string, value any) bool { } case TimePickerStep: - oldStep := GetTimePickerStep(picker, "") + oldStep := GetTimePickerStep(picker) if picker.setIntProperty(TimePickerStep, value) { - if step := GetTimePickerStep(picker, ""); oldStep != step { + if step := GetTimePickerStep(picker); oldStep != step { if picker.created { if step > 0 { updateProperty(picker.htmlID(), Step, strconv.Itoa(step), picker.session) @@ -208,7 +208,7 @@ func (picker *timePickerData) set(tag string, value any) bool { } case TimePickerValue: - oldTime := GetTimePickerValue(picker, "") + oldTime := GetTimePickerValue(picker) if time, ok := setTimeValue(TimePickerValue); ok { if time != oldTime { if picker.created { @@ -282,7 +282,7 @@ func (picker *timePickerData) htmlProperties(self View, buffer *strings.Builder) } buffer.WriteString(` value="`) - buffer.WriteString(GetTimePickerValue(picker, "").Format(timeFormat)) + buffer.WriteString(GetTimePickerValue(picker).Format(timeFormat)) buffer.WriteByte('"') buffer.WriteString(` oninput="editViewInputEvent(this)"`) @@ -292,7 +292,7 @@ func (picker *timePickerData) htmlProperties(self View, buffer *strings.Builder) } func (picker *timePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` disabled`) } picker.viewData.htmlDisabledProperties(self, buffer) @@ -303,7 +303,7 @@ func (picker *timePickerData) handleCommand(self View, command string, data Data case "textChanged": if text, ok := data.PropertyValue("text"); ok { if value, err := time.Parse(timeFormat, text); err == nil { - oldValue := GetTimePickerValue(picker, "") + oldValue := GetTimePickerValue(picker) picker.properties[TimePickerValue] = value if value != oldValue { for _, listener := range picker.timeChangedListeners { @@ -353,10 +353,10 @@ func getTimeProperty(view View, mainTag, shortTag string) (time.Time, bool) { // GetTimePickerMin returns the min time of TimePicker subview and "true" as the second value if the min time is set, // "false" as the second value otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTimePickerMin(view View, subviewID string) (time.Time, bool) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getTimeProperty(view, TimePickerMin, Min) @@ -366,10 +366,10 @@ func GetTimePickerMin(view View, subviewID string) (time.Time, bool) { // GetTimePickerMax returns the max time of TimePicker subview and "true" as the second value if the min time is set, // "false" as the second value otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTimePickerMax(view View, subviewID string) (time.Time, bool) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getTimeProperty(view, TimePickerMax, Max) @@ -378,16 +378,16 @@ func GetTimePickerMax(view View, subviewID string) (time.Time, bool) { } // GetTimePickerStep returns the time changing step in seconds of TimePicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTimePickerStep(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTimePickerStep(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, TimePickerStep, 60) } // GetTimePickerValue returns the time of TimePicker subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTimePickerValue(view View, subviewID string) time.Time { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTimePickerValue(view View, subviewID ...string) time.Time { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return time.Now() @@ -398,7 +398,7 @@ func GetTimePickerValue(view View, subviewID string) time.Time { // GetTimeChangedListeners returns the TimeChangedListener list of an TimePicker subview. // If there are no listeners then the empty list is returned -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTimeChangedListeners(view View, subviewID string) []func(TimePicker, time.Time) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTimeChangedListeners(view View, subviewID ...string) []func(TimePicker, time.Time) { return getEventListeners[TimePicker, time.Time](view, subviewID, TimeChangedEvent) } diff --git a/touchEvents.go b/touchEvents.go index ac8a410..09d4788 100644 --- a/touchEvents.go +++ b/touchEvents.go @@ -170,7 +170,7 @@ func (event *TouchEvent) init(data DataObject) { } func handleTouchEvents(view View, tag string, data DataObject) { - listeners := getEventListeners[View, TouchEvent](view, "", tag) + listeners := getEventListeners[View, TouchEvent](view, nil, tag) if len(listeners) == 0 { return } @@ -184,25 +184,25 @@ func handleTouchEvents(view View, tag string, data DataObject) { } // GetTouchStartListeners returns the "touch-start" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTouchStartListeners(view View, subviewID string) []func(View, TouchEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTouchStartListeners(view View, subviewID ...string) []func(View, TouchEvent) { return getEventListeners[View, TouchEvent](view, subviewID, TouchStart) } // GetTouchEndListeners returns the "touch-end" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTouchEndListeners(view View, subviewID string) []func(View, TouchEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTouchEndListeners(view View, subviewID ...string) []func(View, TouchEvent) { return getEventListeners[View, TouchEvent](view, subviewID, TouchEnd) } // GetTouchMoveListeners returns the "touch-move" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTouchMoveListeners(view View, subviewID string) []func(View, TouchEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTouchMoveListeners(view View, subviewID ...string) []func(View, TouchEvent) { return getEventListeners[View, TouchEvent](view, subviewID, TouchMove) } // GetTouchCancelListeners returns the "touch-cancel" listener list. If there are no listeners then the empty list is returned. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTouchCancelListeners(view View, subviewID string) []func(View, TouchEvent) { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTouchCancelListeners(view View, subviewID ...string) []func(View, TouchEvent) { return getEventListeners[View, TouchEvent](view, subviewID, TouchCancel) } diff --git a/view.go b/view.go index f2f0bd3..39c9848 100644 --- a/view.go +++ b/view.go @@ -195,7 +195,7 @@ func (view *viewData) remove(tag string) { case Style, StyleDisabled: if _, ok := view.properties[tag]; ok { delete(view.properties, tag) - updateProperty(view.htmlID(), "class", view.htmlClass(IsDisabled(view, "")), view.session) + updateProperty(view.htmlID(), "class", view.htmlClass(IsDisabled(view)), view.session) } case FocusEvent, LostFocusEvent: @@ -325,7 +325,7 @@ func (view *viewData) set(tag string, value any) bool { } view.properties[tag] = text if view.created { - updateProperty(view.htmlID(), "class", view.htmlClass(IsDisabled(view, "")), view.session) + updateProperty(view.htmlID(), "class", view.htmlClass(IsDisabled(view)), view.session) } case FocusEvent, LostFocusEvent: @@ -379,7 +379,7 @@ func viewPropertyChanged(view *viewData, tag string) { return case Visibility: - switch GetVisibility(view, "") { + switch GetVisibility(view) { case Invisible: updateCSSProperty(htmlID, Visibility, "hidden", session) updateCSSProperty(htmlID, "display", "", session) @@ -448,7 +448,7 @@ func viewPropertyChanged(view *viewData, tag string) { return case Outline, OutlineColor, OutlineStyle, OutlineWidth: - updateCSSProperty(htmlID, Outline, GetOutline(view, "").cssString(), session) + updateCSSProperty(htmlID, Outline, GetOutline(view).cssString(), session) return case Shadow: @@ -463,19 +463,19 @@ func viewPropertyChanged(view *viewData, tag string) { RadiusTopRight, RadiusTopRightX, RadiusTopRightY, RadiusBottomLeft, RadiusBottomLeftX, RadiusBottomLeftY, RadiusBottomRight, RadiusBottomRightX, RadiusBottomRightY: - radius := GetRadius(view, "") + radius := GetRadius(view) updateCSSProperty(htmlID, "border-radius", radius.cssString(), session) return case Margin, MarginTop, MarginRight, MarginBottom, MarginLeft, "top-margin", "right-margin", "bottom-margin", "left-margin": - margin := GetMargin(view, "") + margin := GetMargin(view) updateCSSProperty(htmlID, Margin, margin.cssString(), session) return case Padding, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, "top-padding", "right-padding", "bottom-padding", "left-padding": - padding := GetPadding(view, "") + padding := GetPadding(view) updateCSSProperty(htmlID, Padding, padding.cssString(), session) return @@ -680,7 +680,7 @@ func (view *viewData) get(tag string) any { } func (view *viewData) htmlTag() string { - if semantics := GetSemantics(view, ""); semantics > DefaultSemantics { + if semantics := GetSemantics(view); semantics > DefaultSemantics { values := enumProperties[Semantics].cssValues if semantics < len(values) { return values[semantics] @@ -709,7 +709,7 @@ func (view *viewData) addToCSSStyle(addCSS map[string]string) { func (view *viewData) cssStyle(self View, builder cssBuilder) { view.viewStyle.cssViewStyle(builder, view.session) - switch GetVisibility(view, "") { + switch GetVisibility(view) { case Invisible: builder.add(`visibility`, `hidden`) @@ -733,7 +733,7 @@ func (view *viewData) htmlProperties(self View, buffer *strings.Builder) { } func (view *viewData) htmlDisabledProperties(self View, buffer *strings.Builder) { - if IsDisabled(self, "") { + if IsDisabled(self) { buffer.WriteString(` data-disabled="1"`) } else { buffer.WriteString(` data-disabled="0"`) @@ -748,7 +748,7 @@ func viewHTML(view View, buffer *strings.Builder) { buffer.WriteString(view.htmlID()) buffer.WriteRune('"') - disabled := IsDisabled(view, "") + disabled := IsDisabled(view) if cls := view.htmlClass(disabled); cls != "" { buffer.WriteString(` class="`) @@ -825,7 +825,7 @@ func (view *viewData) handleCommand(self View, command string, data DataObject) switch command { case KeyDownEvent, KeyUpEvent: - if !IsDisabled(self, "") { + if !IsDisabled(self) { handleKeyEvents(self, command, data) } @@ -840,13 +840,13 @@ func (view *viewData) handleCommand(self View, command string, data DataObject) case FocusEvent: view.hasFocus = true - for _, listener := range getFocusListeners(view, "", command) { + for _, listener := range getFocusListeners(view, nil, command) { listener(self) } case LostFocusEvent: view.hasFocus = false - for _, listener := range getFocusListeners(view, "", command) { + for _, listener := range getFocusListeners(view, nil, command) { listener(self) } diff --git a/viewClip.go b/viewClip.go index 1ed892f..2f61010 100644 --- a/viewClip.go +++ b/viewClip.go @@ -558,10 +558,10 @@ func getClipShape(prop Properties, tag string, session Session) ClipShape { } // GetClip returns a View clipping area. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetClip(view View, subviewID string) ClipShape { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetClip(view View, subviewID ...string) ClipShape { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getClipShape(view, Clip, view.Session()) @@ -571,10 +571,10 @@ func GetClip(view View, subviewID string) ClipShape { } // GetShapeOutside returns a shape around which adjacent inline content. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetShapeOutside(view View, subviewID string) ClipShape { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetShapeOutside(view View, subviewID ...string) ClipShape { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { return getClipShape(view, ShapeOutside, view.Session()) diff --git a/viewFilter.go b/viewFilter.go index a19cd52..7b35939 100644 --- a/viewFilter.go +++ b/viewFilter.go @@ -259,34 +259,46 @@ func (style *viewStyle) setFilter(tag string, value any) bool { } // GetFilter returns a View graphical effects like blur or color shift. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetFilter(view View, subviewID string) ViewFilter { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetFilter(view View, subviewID ...string) ViewFilter { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value := view.getRaw(Filter); value != nil { if filter, ok := value.(ViewFilter); ok { return filter } } + if value := valueFromStyle(view, Filter); value != nil { + if filter, ok := value.(ViewFilter); ok { + return filter + } + } } return nil } // GetBackdropFilter returns the area behind a View graphical effects like blur or color shift. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetBackdropFilter(view View, subviewID string) ViewFilter { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetBackdropFilter(view View, subviewID ...string) ViewFilter { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value := view.getRaw(BackdropFilter); value != nil { if filter, ok := value.(ViewFilter); ok { return filter } } + if value := valueFromStyle(view, BackdropFilter); value != nil { + if filter, ok := value.(ViewFilter); ok { + return filter + } + } } return nil diff --git a/viewTransform.go b/viewTransform.go index af0adbd..6625c19 100644 --- a/viewTransform.go +++ b/viewTransform.go @@ -245,7 +245,7 @@ func (view *viewData) updateTransformProperty(tag string) bool { case PerspectiveOriginX, PerspectiveOriginY: if getTransform3D(view, session) { - x, y := GetPerspectiveOrigin(view, "") + x, y := GetPerspectiveOrigin(view) value := "" if x.Type != Auto || y.Type != Auto { value = x.cssString("50%") + " " + y.cssString("50%") @@ -255,7 +255,7 @@ func (view *viewData) updateTransformProperty(tag string) bool { case BackfaceVisible: if getTransform3D(view, session) { - if GetBackfaceVisible(view, "") { + if GetBackfaceVisible(view) { updateCSSProperty(htmlID, BackfaceVisible, "visible", session) } else { updateCSSProperty(htmlID, BackfaceVisible, "hidden", session) diff --git a/viewUtils.go b/viewUtils.go index 10cf27f..9cf0f8d 100644 --- a/viewUtils.go +++ b/viewUtils.go @@ -33,7 +33,7 @@ func Set(rootView View, viewID, tag string, value any) bool { } // SetChangeListener sets a listener for changing a subview property value. -// If the second argument (subviewID) is "" then a listener for the first argument (view) is set +// If the second argument (subviewID) is not specified or it is "" then a listener for the first argument (view) is set func SetChangeListener(view View, viewID, tag string, listener func(View, string)) { if viewID != "" { view = ViewByID(view, viewID) @@ -65,17 +65,17 @@ func SetParams(rootView View, viewID string, params Params) bool { } // IsDisabled returns "true" if the subview is disabled -// If the second argument (subviewID) is "" then a state of the first argument (view) is returned -func IsDisabled(view View, subviewID string) bool { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a state of the first argument (view) is returned +func IsDisabled(view View, subviewID ...string) bool { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if disabled, _ := boolProperty(view, Disabled, view.Session()); disabled { return true } if parent := view.Parent(); parent != nil { - return IsDisabled(parent, "") + return IsDisabled(parent) } } return false @@ -86,22 +86,22 @@ func IsDisabled(view View, subviewID string) bool { // HeaderSemantics (4), MainSemantics (5), FooterSemantics (6), NavigationSemantics (7), // FigureSemantics (8), FigureCaptionSemantics (9), ButtonSemantics (10), ParagraphSemantics (11), // H1Semantics (12) - H6Semantics (17), BlockquoteSemantics (18), and CodeSemantics (19). -// If the second argument (subviewID) is "" then a semantics of the first argument (view) is returned -func GetSemantics(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a semantics of the first argument (view) is returned +func GetSemantics(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, Semantics, DefaultSemantics, false) } // GetOpacity returns the subview opacity. -// If the second argument (subviewID) is "" then an opacity of the first argument (view) is returned -func GetOpacity(view View, subviewID string) float64 { +// If the second argument (subviewID) is not specified or it is "" then an opacity of the first argument (view) is returned +func GetOpacity(view View, subviewID ...string) float64 { return floatStyledProperty(view, subviewID, Opacity, 1) } // GetStyle returns the subview style id. -// If the second argument (subviewID) is "" then a style of the first argument (view) is returned -func GetStyle(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned +func GetStyle(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if style, ok := stringProperty(view, Style, view.Session()); ok { @@ -112,10 +112,10 @@ func GetStyle(view View, subviewID string) string { } // GetDisabledStyle returns the disabled subview style id. -// If the second argument (subviewID) is "" then a style of the first argument (view) is returned -func GetDisabledStyle(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a style of the first argument (view) is returned +func GetDisabledStyle(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if style, ok := stringProperty(view, StyleDisabled, view.Session()); ok { @@ -127,19 +127,19 @@ func GetDisabledStyle(view View, subviewID string) string { // GetVisibility returns the subview visibility. One of the following values is returned: // Visible (0), Invisible (1), or Gone (2) -// If the second argument (subviewID) is "" then a visibility of the first argument (view) is returned -func GetVisibility(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a visibility of the first argument (view) is returned +func GetVisibility(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, Visibility, Visible, false) } // GetOverflow returns a value of the subview "overflow" property. Returns one of next values: // OverflowHidden (0), OverflowVisible (1), OverflowScroll (2), OverflowAuto (3) -// If the second argument (subviewID) is "" then a value of the first argument (view) is returned -func GetOverflow(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned +func GetOverflow(view View, subviewID ...string) int { defaultOverflow := OverflowHidden view2 := view - if subviewID != "" { - view2 = ViewByID(view, subviewID) + if len(subviewID) > 0 && subviewID[0] != "" { + view2 = ViewByID(view, subviewID[0]) } if view2 != nil { switch view.(type) { @@ -154,87 +154,87 @@ func GetOverflow(view View, subviewID string) int { } // GetZIndex returns the subview z-order. -// If the second argument (subviewID) is "" then a z-order of the first argument (view) is returned -func GetZIndex(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a z-order of the first argument (view) is returned +func GetZIndex(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, ZIndex, 0) } // GetWidth returns the subview width. -// If the second argument (subviewID) is "" then a width of the first argument (view) is returned -func GetWidth(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned +func GetWidth(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Width, false) } // GetHeight returns the subview height. -// If the second argument (subviewID) is "" then a height of the first argument (view) is returned -func GetHeight(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a height of the first argument (view) is returned +func GetHeight(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Height, false) } // GetMinWidth returns a minimal subview width. -// If the second argument (subviewID) is "" then a minimal width of the first argument (view) is returned -func GetMinWidth(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a minimal width of the first argument (view) is returned +func GetMinWidth(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, MinWidth, false) } // GetMinHeight returns a minimal subview height. -// If the second argument (subviewID) is "" then a minimal height of the first argument (view) is returned -func GetMinHeight(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a minimal height of the first argument (view) is returned +func GetMinHeight(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, MinHeight, false) } // GetMaxWidth returns a maximal subview width. -// If the second argument (subviewID) is "" then a maximal width of the first argument (view) is returned -func GetMaxWidth(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a maximal width of the first argument (view) is returned +func GetMaxWidth(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, MaxWidth, false) } // GetMaxHeight returns a maximal subview height. -// If the second argument (subviewID) is "" then a maximal height of the first argument (view) is returned -func GetMaxHeight(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a maximal height of the first argument (view) is returned +func GetMaxHeight(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, MaxHeight, false) } // GetResize returns the "resize" property value if the subview. One of the following values is returned: // NoneResize (0), BothResize (1), HorizontalResize (2), or VerticalResize (3) -// If the second argument (subviewID) is "" then a value of the first argument (view) is returned -func GetResize(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value of the first argument (view) is returned +func GetResize(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, Resize, NoneResize, false) } // GetLeft returns a left position of the subview in an AbsoluteLayout container. // If a parent view is not an AbsoluteLayout container then this value is ignored. -// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned -func GetLeft(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a left position of the first argument (view) is returned +func GetLeft(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Left, false) } // GetRight returns a right position of the subview in an AbsoluteLayout container. // If a parent view is not an AbsoluteLayout container then this value is ignored. -// If the second argument (subviewID) is "" then a right position of the first argument (view) is returned -func GetRight(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a right position of the first argument (view) is returned +func GetRight(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Right, false) } // GetTop returns a top position of the subview in an AbsoluteLayout container. // If a parent view is not an AbsoluteLayout container then this value is ignored. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetTop(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetTop(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Top, false) } // GetBottom returns a top position of the subview in an AbsoluteLayout container. // If a parent view is not an AbsoluteLayout container then this value is ignored. -// If the second argument (subviewID) is "" then a bottom position of the first argument (view) is returned -func GetBottom(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a bottom position of the first argument (view) is returned +func GetBottom(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Bottom, false) } // Margin returns the subview margin. -// If the second argument (subviewID) is "" then a margin of the first argument (view) is returned -func GetMargin(view View, subviewID string) Bounds { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a margin of the first argument (view) is returned +func GetMargin(view View, subviewID ...string) Bounds { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } var bounds Bounds if view != nil { @@ -244,10 +244,10 @@ func GetMargin(view View, subviewID string) Bounds { } // GetPadding returns the subview padding. -// If the second argument (subviewID) is "" then a padding of the first argument (view) is returned -func GetPadding(view View, subviewID string) Bounds { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a padding of the first argument (view) is returned +func GetPadding(view View, subviewID ...string) Bounds { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } var bounds Bounds if view != nil { @@ -257,10 +257,10 @@ func GetPadding(view View, subviewID string) Bounds { } // GetBorder returns ViewBorders of the subview. -// If the second argument (subviewID) is "" then a ViewBorders of the first argument (view) is returned. -func GetBorder(view View, subviewID string) ViewBorders { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a ViewBorders of the first argument (view) is returned. +func GetBorder(view View, subviewID ...string) ViewBorders { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if border := getBorder(view, Border); border != nil { @@ -271,10 +271,10 @@ func GetBorder(view View, subviewID string) ViewBorders { } // Radius returns the BoxRadius structure of the subview. -// If the second argument (subviewID) is "" then a BoxRadius of the first argument (view) is returned. -func GetRadius(view View, subviewID string) BoxRadius { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a BoxRadius of the first argument (view) is returned. +func GetRadius(view View, subviewID ...string) BoxRadius { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return BoxRadius{} @@ -283,10 +283,10 @@ func GetRadius(view View, subviewID string) BoxRadius { } // GetOutline returns ViewOutline of the subview. -// If the second argument (subviewID) is "" then a ViewOutline of the first argument (view) is returned. -func GetOutline(view View, subviewID string) ViewOutline { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a ViewOutline of the first argument (view) is returned. +func GetOutline(view View, subviewID ...string) ViewOutline { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if outline := getOutline(view); outline != nil { @@ -297,10 +297,10 @@ func GetOutline(view View, subviewID string) ViewOutline { } // GetViewShadows returns shadows of the subview. -// If the second argument (subviewID) is "" then shadows of the first argument (view) is returned. -func GetViewShadows(view View, subviewID string) []ViewShadow { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned. +func GetViewShadows(view View, subviewID ...string) []ViewShadow { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return []ViewShadow{} @@ -309,10 +309,10 @@ func GetViewShadows(view View, subviewID string) []ViewShadow { } // GetTextShadows returns text shadows of the subview. -// If the second argument (subviewID) is "" then shadows of the first argument (view) is returned. -func GetTextShadows(view View, subviewID string) []ViewShadow { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then shadows of the first argument (view) is returned. +func GetTextShadows(view View, subviewID ...string) []ViewShadow { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return []ViewShadow{} @@ -321,22 +321,22 @@ func GetTextShadows(view View, subviewID string) []ViewShadow { } // GetBackgroundColor returns a background color of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetBackgroundColor(view View, subviewID string) Color { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetBackgroundColor(view View, subviewID ...string) Color { return colorStyledProperty(view, subviewID, BackgroundColor, false) } // GetAccentColor returns the accent color for UI controls generated by some elements. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetAccentColor(view View, subviewID string) Color { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetAccentColor(view View, subviewID ...string) Color { return colorStyledProperty(view, subviewID, AccentColor, false) } // GetFontName returns the subview font. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetFontName(view View, subviewID string) string { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetFontName(view View, subviewID ...string) string { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if font, ok := stringProperty(view, FontName, view.Session()); ok { @@ -348,34 +348,34 @@ func GetFontName(view View, subviewID string) string { } } if parent := view.Parent(); parent != nil { - return GetFontName(parent, "") + return GetFontName(parent) } } return "" } // GetTextColor returns a text color of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextColor(view View, subviewID string) Color { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextColor(view View, subviewID ...string) Color { return colorStyledProperty(view, subviewID, TextColor, true) } // GetTextSize returns a text size of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextSize(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextSize(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, TextSize, true) } // GetTabSize returns the subview width of tab characters (U+0009) in spaces. -// If the second argument (subviewID) is "" then a width of the first argument (view) is returned -func GetTabSize(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a width of the first argument (view) is returned +func GetTabSize(view View, subviewID ...string) int { return intStyledProperty(view, subviewID, TabSize, 8) } // GetTextWeight returns a text weight of the subview. Returns one of next values: // 1, 2, 3, 4 (normal text), 5, 6, 7 (bold text), 8 and 9 -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextWeight(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextWeight(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TextWeight, NormalFont, true) } @@ -383,105 +383,105 @@ func GetTextWeight(view View, subviewID string) int { // // LeftAlign = 0, RightAlign = 1, CenterAlign = 2, JustifyAlign = 3 // -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextAlign(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextAlign(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TextAlign, LeftAlign, true) } // GetTextIndent returns a text indent of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextIndent(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextIndent(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, TextIndent, true) } // GetLetterSpacing returns a letter spacing of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetLetterSpacing(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetLetterSpacing(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, LetterSpacing, true) } // GetWordSpacing returns a word spacing of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetWordSpacing(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetWordSpacing(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, WordSpacing, true) } // GetLineHeight returns a height of a text line of the subview. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetLineHeight(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetLineHeight(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, LineHeight, true) } // IsItalic returns "true" if a text font of the subview is displayed in italics, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsItalic(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsItalic(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Italic, true) } // IsSmallCaps returns "true" if a text font of the subview is displayed in small caps, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsSmallCaps(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsSmallCaps(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, SmallCaps, true) } // IsStrikethrough returns "true" if a text font of the subview is displayed strikethrough, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsStrikethrough(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsStrikethrough(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Strikethrough, true) } // IsOverline returns "true" if a text font of the subview is displayed overlined, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsOverline(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsOverline(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Overline, true) } // IsUnderline returns "true" if a text font of the subview is displayed underlined, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsUnderline(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsUnderline(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, Underline, true) } // GetTextLineThickness returns the stroke thickness of the decoration line that // is used on text in an element, such as a line-through, underline, or overline. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextLineThickness(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextLineThickness(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, TextLineThickness, true) } // GetTextLineStyle returns the stroke style of the decoration line that // is used on text in an element, such as a line-through, underline, or overline. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextLineStyle(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextLineStyle(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TextLineStyle, SolidLine, true) } // GetTextLineColor returns the stroke color of the decoration line that // is used on text in an element, such as a line-through, underline, or overline. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextLineColor(view View, subviewID string) Color { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextLineColor(view View, subviewID ...string) Color { return colorStyledProperty(view, subviewID, TextLineColor, true) } // GetTextTransform returns a text transform of the subview. Return one of next values: // NoneTextTransform (0), CapitalizeTextTransform (1), LowerCaseTextTransform (2) or UpperCaseTextTransform (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextTransform(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextTransform(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, TextTransform, NoneTextTransform, true) } // GetWritingMode returns whether lines of text are laid out horizontally or vertically, as well as // the direction in which blocks progress. Valid values are HorizontalTopToBottom (0), // HorizontalBottomToTop (1), VerticalRightToLeft (2) and VerticalLeftToRight (3) -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetWritingMode(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetWritingMode(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, WritingMode, HorizontalTopToBottom, true) } // GetTextDirection - returns a direction of text, table columns, and horizontal overflow. // Valid values are SystemTextDirection (0), LeftToRightDirection (1), and RightToLeftDirection (2). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTextDirection(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTextDirection(view View, subviewID ...string) int { if view == nil { return SystemTextDirection } @@ -492,16 +492,16 @@ func GetTextDirection(view View, subviewID string) int { // GetVerticalTextOrientation returns a orientation of the text characters in a line. It only affects text // in vertical mode (when "writing-mode" is "vertical-right-to-left" or "vertical-left-to-right"). // Valid values are MixedTextOrientation (0), UprightTextOrientation (1), and SidewaysTextOrientation (2). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetVerticalTextOrientation(view View, subviewID string) int { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetVerticalTextOrientation(view View, subviewID ...string) int { return enumStyledProperty(view, subviewID, VerticalTextOrientation, MixedTextOrientation, true) } // GetRow returns the range of row numbers of a GridLayout in which the subview is placed. -// If the second argument (subviewID) is "" then a values from the first argument (view) is returned. -func GetRow(view View, subviewID string) Range { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned. +func GetRow(view View, subviewID ...string) Range { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { session := view.Session() @@ -518,10 +518,10 @@ func GetRow(view View, subviewID string) Range { } // GetColumn returns the range of column numbers of a GridLayout in which the subview is placed. -// If the second argument (subviewID) is "" then a values from the first argument (view) is returned. -func GetColumn(view View, subviewID string) Range { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a values from the first argument (view) is returned. +func GetColumn(view View, subviewID ...string) Range { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { session := view.Session() @@ -540,17 +540,17 @@ func GetColumn(view View, subviewID string) Range { // GetPerspective returns a distance between the z = 0 plane and the user in order to give a 3D-positioned // element some perspective. Each 3D element with z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. // The default value is 0 (no 3D effects). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPerspective(view View, subviewID string) SizeUnit { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPerspective(view View, subviewID ...string) SizeUnit { return sizeStyledProperty(view, subviewID, Perspective, false) } // GetPerspectiveOrigin returns a x- and y-coordinate of the position at which the viewer is looking. // It is used as the vanishing point by the Perspective property. The default value is (50%, 50%). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetPerspectiveOrigin(view View, subviewID string) (SizeUnit, SizeUnit) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetPerspectiveOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return AutoSize(), AutoSize() @@ -562,17 +562,17 @@ func GetPerspectiveOrigin(view View, subviewID string) (SizeUnit, SizeUnit) { // visible when turned towards the user. Values: // true - the back face is visible when turned towards the user (default value). // false - the back face is hidden, effectively making the element invisible when turned away from the user. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetBackfaceVisible(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetBackfaceVisible(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, BackfaceVisible, false) } // GetOrigin returns a x-, y-, and z-coordinate of the point around which a view transformation is applied. // The default value is (50%, 50%, 50%). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetOrigin(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetOrigin(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return AutoSize(), AutoSize(), AutoSize() @@ -581,10 +581,10 @@ func GetOrigin(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) { } // GetTranslate returns a x-, y-, and z-axis translation value of a 2D/3D translation -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetTranslate(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetTranslate(view View, subviewID ...string) (SizeUnit, SizeUnit, SizeUnit) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return AutoSize(), AutoSize(), AutoSize() @@ -594,10 +594,10 @@ func GetTranslate(view View, subviewID string) (SizeUnit, SizeUnit, SizeUnit) { // GetSkew returns a angles to use to distort the element along the abscissa (x-axis) // and the ordinate (y-axis). The default value is 0. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetSkew(view View, subviewID string) (AngleUnit, AngleUnit) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetSkew(view View, subviewID ...string) (AngleUnit, AngleUnit) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return AngleUnit{Value: 0, Type: Radian}, AngleUnit{Value: 0, Type: Radian} @@ -607,10 +607,10 @@ func GetSkew(view View, subviewID string) (AngleUnit, AngleUnit) { } // GetScale returns a x-, y-, and z-axis scaling value of a 2D/3D scale. The default value is 1. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetScale(view View, subviewID string) (float64, float64, float64) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetScale(view View, subviewID ...string) (float64, float64, float64) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return 1, 1, 1 @@ -624,10 +624,10 @@ func GetScale(view View, subviewID string) (float64, float64, float64) { } // GetRotate returns a x-, y, z-coordinate of the vector denoting the axis of rotation, and the angle of the view rotation -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetRotate(view View, subviewID string) (float64, float64, float64, AngleUnit) { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetRotate(view View, subviewID ...string) (float64, float64, float64, AngleUnit) { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view == nil { return 0, 0, 0, AngleUnit{Value: 0, Type: Radian} @@ -643,12 +643,12 @@ func GetRotate(view View, subviewID string) (float64, float64, float64, AngleUni // GetAvoidBreak returns "true" if avoids any break from being inserted within the principal box, // and "false" if allows, but does not force, any break to be inserted within the principal box. -// If the second argument (subviewID) is "" then a top position of the first argument (view) is returned -func GetAvoidBreak(view View, subviewID string) bool { +// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned +func GetAvoidBreak(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, AvoidBreak, true) } -func GetNotTranslate(view View, subviewID string) bool { +func GetNotTranslate(view View, subviewID ...string) bool { return boolStyledProperty(view, subviewID, NotTranslate, true) } @@ -663,7 +663,7 @@ func valueFromStyle(view View, tag string) any { return nil } - if IsDisabled(view, "") { + if IsDisabled(view) { if value := getValue(StyleDisabled); value != nil { return value } @@ -671,10 +671,11 @@ func valueFromStyle(view View, tag string) any { return getValue(Style) } -func sizeStyledProperty(view View, subviewID string, tag string, inherit bool) SizeUnit { - if subviewID != "" { - view = ViewByID(view, subviewID) +func sizeStyledProperty(view View, subviewID []string, tag string, inherit bool) SizeUnit { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value, ok := sizeProperty(view, tag, view.Session()); ok { return value @@ -687,17 +688,18 @@ func sizeStyledProperty(view View, subviewID string, tag string, inherit bool) S if inherit { if parent := view.Parent(); parent != nil { - return sizeStyledProperty(parent, "", tag, true) + return sizeStyledProperty(parent, []string{}, tag, true) } } } return AutoSize() } -func enumStyledProperty(view View, subviewID string, tag string, defaultValue int, inherit bool) int { - if subviewID != "" { - view = ViewByID(view, subviewID) +func enumStyledProperty(view View, subviewID []string, tag string, defaultValue int, inherit bool) int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value, ok := enumProperty(view, tag, view.Session(), defaultValue); ok { return value @@ -710,16 +712,16 @@ func enumStyledProperty(view View, subviewID string, tag string, defaultValue in if inherit { if parent := view.Parent(); parent != nil { - return enumStyledProperty(parent, "", tag, defaultValue, true) + return enumStyledProperty(parent, []string{}, tag, defaultValue, true) } } } return defaultValue } -func boolStyledProperty(view View, subviewID string, tag string, inherit bool) bool { - if subviewID != "" { - view = ViewByID(view, subviewID) +func boolStyledProperty(view View, subviewID []string, tag string, inherit bool) bool { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -734,7 +736,7 @@ func boolStyledProperty(view View, subviewID string, tag string, inherit bool) b if inherit { if parent := view.Parent(); parent != nil { - return boolStyledProperty(parent, "", tag, inherit) + return boolStyledProperty(parent, []string{}, tag, inherit) } } } @@ -742,10 +744,11 @@ func boolStyledProperty(view View, subviewID string, tag string, inherit bool) b return false } -func intStyledProperty(view View, subviewID string, tag string, defaultValue int) int { - if subviewID != "" { - view = ViewByID(view, subviewID) +func intStyledProperty(view View, subviewID []string, tag string, defaultValue int) int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } + if view != nil { if value, ok := intProperty(view, tag, view.Session(), defaultValue); ok { return value @@ -758,9 +761,9 @@ func intStyledProperty(view View, subviewID string, tag string, defaultValue int return defaultValue } -func floatStyledProperty(view View, subviewID string, tag string, defaultValue float64) float64 { - if subviewID != "" { - view = ViewByID(view, subviewID) +func floatStyledProperty(view View, subviewID []string, tag string, defaultValue float64) float64 { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value, ok := floatProperty(view, tag, view.Session(), defaultValue); ok { @@ -774,9 +777,9 @@ func floatStyledProperty(view View, subviewID string, tag string, defaultValue f return defaultValue } -func colorStyledProperty(view View, subviewID, tag string, inherit bool) Color { - if subviewID != "" { - view = ViewByID(view, subviewID) +func colorStyledProperty(view View, subviewID []string, tag string, inherit bool) Color { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { if value, ok := colorProperty(view, tag, view.Session()); ok { @@ -789,7 +792,7 @@ func colorStyledProperty(view View, subviewID, tag string, inherit bool) Color { } if inherit { if parent := view.Parent(); parent != nil { - return colorStyledProperty(parent, "", tag, true) + return colorStyledProperty(parent, []string{}, tag, true) } } } @@ -827,10 +830,10 @@ func BlurViewByID(viewID string, session Session) { } // GetCurrent returns the index of the selected item (<0 if there is no a selected item) or the current view index (StackLayout, TabsLayout). -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func GetCurrent(view View, subviewID string) int { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func GetCurrent(view View, subviewID ...string) int { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } defaultValue := -1 @@ -845,10 +848,10 @@ func GetCurrent(view View, subviewID string) int { } // IsUserSelect returns "true" if the user can select text, "false" otherwise. -// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. -func IsUserSelect(view View, subviewID string) bool { - if subviewID != "" { - view = ViewByID(view, subviewID) +// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned. +func IsUserSelect(view View, subviewID ...string) bool { + if len(subviewID) > 0 && subviewID[0] != "" { + view = ViewByID(view, subviewID[0]) } if view != nil { @@ -875,7 +878,7 @@ func isUserSelect(view View) (bool, bool) { } } - switch GetSemantics(view, "") { + switch GetSemantics(view) { case ParagraphSemantics, H1Semantics, H2Semantics, H3Semantics, H4Semantics, H5Semantics, H6Semantics, BlockquoteSemantics, CodeSemantics: return true, false diff --git a/viewsContainer.go b/viewsContainer.go index e68df72..549d9bd 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -186,9 +186,9 @@ func (container *viewsContainerData) set(tag string, value any) bool { // do nothing case Disabled: - oldDisabled := IsDisabled(container, "") + oldDisabled := IsDisabled(container) if container.viewData.Set(Disabled, value) { - disabled := IsDisabled(container, "") + disabled := IsDisabled(container) if oldDisabled != disabled { if container.views != nil { for _, view := range container.views {