// Button creates a default generic button
2916
func Button(name string, text string) *Field {
	ret := FieldWithType(name, formcommon.BUTTON)
	ret.SetText(text)
	return ret
}
129414
func ButtonLeft(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams {
	return p.WithButton(input.ButtonLeft)
}
189530
func (f Form) RadioButtonTag(opts tags.Options) *tags.Tag {
	opts["type"] = "radio"

	var label string
	if opts["label"] != nil {
		label = fmt.Sprint(opts["label"])
		delete(opts, "label")
	}
	var ID string
	if opts["id"] != nil {
		ID = fmt.Sprint(opts["id"])
	}

	value := opts["value"]
	checked := opts["checked"]
	delete(opts, "checked")

	if opts["tag_only"] == true {
		ct := f.InputTag(opts)
		ct.Checked = template.HTMLEscaper(value) == template.HTMLEscaper(checked)
		return ct
	}

	ct := f.InputTag(opts)
	ct.Checked = template.HTMLEscaper(value) == template.HTMLEscaper(checked)
	labelOptions := tags.Options{
		"body": strings.Join([]string{ct.String(), label}, " "),
	}
	// If the ID is provided, give it to the label's for attribute
	if ID != "" {
		labelOptions["for"] = ID
	}
	tag := tags.New("label", labelOptions)
	return tag
}
402252
func (f *Form) Focus(delegate func(p Primitive)) {
	if len(f.items)+len(f.buttons) == 0 {
		f.hasFocus = true
		return
	}
	f.hasFocus = false

	// Hand on the focus to one of our child elements.
	if f.focusedElement < 0 || f.focusedElement >= len(f.items)+len(f.buttons) {
		f.focusedElement = 0
	}
	handler := func(key tcell.Key) {
		switch key {
		case tcell.KeyTab, tcell.KeyEnter:
			f.focusedElement++
			f.Focus(delegate)
		case tcell.KeyBacktab:
			f.focusedElement--
			if f.focusedElement < 0 {
				f.focusedElement = len(f.items) + len(f.buttons) - 1
			}
			f.Focus(delegate)
		case tcell.KeyEscape:
			if f.cancel != nil {
				f.cancel()
			} else {
				f.focusedElement = 0
				f.Focus(delegate)
			}
		}
	}

	if f.focusedElement < len(f.items) {
		// We're selecting an item.
		item := f.items[f.focusedElement]
		item.SetFinishedFunc(handler)
		delegate(item)
	} else {
		// We're selecting a button.
		button := f.buttons[f.focusedElement-len(f.items)]
		button.SetBlurFunc(handler)
		delegate(button)
	}
}
1288149
func NewButton(label string) *Button {
	box := NewBox().SetBackgroundColor(Styles.ContrastBackgroundColor)
	box.SetRect(0, 0, TaggedStringWidth(label)+4, 1)
	return &Button{
		Box:                      box,
		label:                    label,
		labelColor:               Styles.PrimaryTextColor,
		labelColorActivated:      Styles.InverseTextColor,
		backgroundColorActivated: Styles.PrimaryTextColor,
	}
}
790627
func (f *Form) Click(button string) error {
	if _, ok := f.buttons[button]; !ok {
		return errors.NewInvalidFormValue(
			"Form does not contain a button with the name '%s'.", button)
	}
	return f.send(button, f.buttons[button][0])
}
954381
func Default() gin.HandlerFunc {
	config := DefaultConfig()
	config.AllowAllOrigins = true
	return New(config)
}
558338
func (keyboard *InlineKeyboard) AddPMSwitchButton(b *Bot, text string, param string) {
	if len(keyboard.Buttons) > 0 && len(keyboard.Buttons[0]) > 0 && keyboard.Buttons[0][0].Text == text {
		return
	}
	keyboard.PrependRows(InlineButtons{InlineButton{Text: text, URL: b.PMURL(param)}})
}
679621
func (js *joystickState) getButton(joystick Joystick, button int) bool {
	// Check that the joystick and button is valid, return false by default
	if js.buttons[joystick] == nil || button >= len(js.buttons[joystick]) || button < 0 {
		return false
	}
	return js.buttons[joystick][byte(button)] == 1
}
317213
func (btn *Button) SetViewButton(name, url string) {
	btn.Type = "view"
	btn.Name = name
	btn.URL = url
	btn.Key = ""
	btn.MediaID = ""
	btn.SubButtons = nil
}
643848
func (bot *TgBot) DefaultSelective(b bool) *TgBot {
	bot.DefaultOptions.Selective = &b
	return bot
}
556155
func drawButton(out *command.Buffer, bounds rect.Rect, state nstyle.WidgetStates, style *nstyle.Button) *nstyle.Item {
	var background *nstyle.Item
	if state&nstyle.WidgetStateHovered != 0 {
		background = &style.Hover
	} else if state&nstyle.WidgetStateActive != 0 {
		background = &style.Active
	} else {
		background = &style.Normal
	}

	if background.Type == nstyle.ItemImage {
		out.DrawImage(bounds, background.Data.Image)
	} else {
		out.FillRect(bounds, style.Rounding, style.BorderColor)
		out.FillRect(shrinkRect(bounds, style.Border), style.Rounding, background.Data.Color)
	}

	return background
}
1143594
func (w *wrapper) GUI() GUIConfiguration {
	w.mut.Lock()
	defer w.mut.Unlock()
	return w.cfg.GUI.Copy()
}
878127
func (buttons *Buttons) InlineButtons() InlineButtons {
	row := InlineButtons{}

	for _, button := range *buttons {
		row.Append(button.Data, button.Text)

	}
	return row
}
1158668
func (b Button) String() string {
	name, ok := buttonNames[b]
	if !ok {
		return "Invalid"
	}
	return name
}
28137
func (c *Context) EditPressedInlineButton(newState int, newText string) error {
	log.WithField("newText", newText).WithField("newState", newState).Info("EditPressedInlineButton")
	if c.Callback == nil {
		return errors.New("EditPressedInlineButton: Callback is not presented")
	}

	return c.EditInlineStateButton(c.Callback.Message, c.Callback.Message.InlineKeyboardMarkup.State, c.Callback.State, c.Callback.Data, newState, newText)
}
734419
func (self *Form) Submit() bool {
	if len(self.buttons) > 0 {
		for name := range self.buttons {
			return self.Click(name)
		}
	}
	return self.send("", "")
}