public void Click() { if (Enabled) { OnButtonClicked?.Invoke(); } }
private void SetupButtons( GridLayoutGroup buttonGroup, Color color, bool drive, string affix = "" ) { var childButtons = buttonGroup.GetComponentsInChildren <Button>(); foreach (var childButton in childButtons) { string buttonName = "Button_" + childButton.transform.GetSiblingIndex() + affix; childButton.name = buttonName; childButton.image.color = color; childButton.GetComponentInChildren <Text>().text = buttonName; childButton.onClick.AddListener(() => { if (drive) { OnButtonClicked?.Invoke(childButton.name); } else { childButton.image.color = Color.red; } }); } }
protected void OnClick(ButtonEventArgs e) { if (wasPreviouslyDown && wasDownInButton && e.ms.LeftButton == ButtonState.Released) { OnButtonClicked?.Invoke(this, e); } if (e.ms.LeftButton == ButtonState.Pressed) { if (!wasPreviouslyDown) { wasPreviouslyDown = true; if (new Rectangle(e.ms.X, e.ms.Y, 1, 1).Intersects(HitBox)) { wasDownInButton = true; } } else if (!new Rectangle(e.ms.X, e.ms.Y, 1, 1).Intersects(HitBox)) { wasDownInButton = false; } } else { wasPreviouslyDown = false; wasDownInButton = false; } }
private void InvokeOnButtonClicked() { if (OnButtonClicked != null) { OnButtonClicked.Invoke(); } }
public void Show(string title, string message, string[] buttons, OnButtonClicked callback) { base.Show(); transform.SetAsLastSibling(); m_delegate = callback; m_title.text = title; m_message.text = message; foreach (var button in m_buttons) { button.SetActive(false); } for (int i = 0; i < buttons.Length; i++) { if (i == m_buttons.Count) { var button = Instantiate(m_buttonTemplate); button.transform.SetParent(FindNested("Panel").transform); m_buttons.Add(button); } m_buttons[i].SetActive(true); m_buttons[i].GetComponent <Button>().onClick.RemoveAllListeners(); m_buttons[i].GetComponentInChildren <Text>().text = buttons[i]; var curIndex = i; m_buttons[i].GetComponent <Button>().onClick.AddListener(() => { OnButtonClickedInt(curIndex); }); } }
public UIButton AddButton(string label, OnButtonClicked buttonClickedEvent) { label.ShouldNotBeNullOrEmpty("label"); buttonClickedEvent.ShouldNotBeNull("buttonClickedEvent"); return((UIButton)UiHelperBase.AddButton(label, buttonClickedEvent)); }
/// <summary> /// 버튼별 정보 지정 /// </summary> public void SetButton(int btnIndex, string btnText, OnButtonClicked btnFunc) { if (btnIndex == 0) { _btn1Text.text = btnText; _btn1.onClick.AddListener(() => { // 클릭시 함수가 지정되어있다면 수행 if (btnFunc != null) { btnFunc(); } // 창닫기 Close(); }); } else if (btnIndex == 1) { _btn2Text.text = btnText; _btn2.onClick.AddListener(() => { if (btnFunc != null) { btnFunc(); } Close(); }); } }
void CreateButton(string label, OnButtonClicked onClicked) { if (GUI.Button(new Rect(200, 150, 150, 50), label)) { onClicked(); } }
private void ButtonClick() { if (OnButtonClicked != null) { SwitchColor(); OnButtonClicked.Invoke(_isEnabled); } }
/// <summary> /// Handles the click. /// </summary> private void HandleClick() { //Check for a null reference before attempting to invoke the event if (OnButtonClicked != null) { OnButtonClicked.Invoke(keyNumber); } }
private void btnRemove_Click(object sender, EventArgs e) { if (groupItem != null) { groupItem.remarks = string.Empty; } OnButtonClicked?.Invoke(sender, e); }
private void button5_Click(object sender, EventArgs e) { ButtonClickedEventArgs a = new ButtonClickedEventArgs() { ActionName = "SHOW_REPORTS", ButtonText = button5.Text }; OnButtonClicked?.Invoke(this, a); }
private static UIButton AddButton(UIHelper group, string text, OnButtonClicked click, float width = 400) { var button = group.AddButton(text, click) as UIButton; button.autoSize = false; button.textHorizontalAlignment = UIHorizontalAlignment.Center; button.width = width; return(button); }
private void ButtonClicked(object sender, EventArgs e) { SelectedIndex = _buttonList.FindIndex(b => b == sender); for (var index = 0; index < _buttonList.Count; index++) { _buttonList[index].TextColor = (index == SelectedIndex) ? Color.White : Color.FromHex("787878"); _buttonList[index].BackgroundColor = (index == SelectedIndex) ? Props.ButtonColor : Color.FromHex("E7E7E7"); } OnButtonClicked?.Invoke(this, SelectedIndex); }
private void CircleButtonControl_OnMouseEventClick(object sender, MouseEventArgs e) { if (m_selectedButton != -1) { if (OnButtonClicked != null) { OnButtonClicked.Invoke(m_buttons[m_selectedButton], null); } } this.Invalidate(); }
private void button3_Click(object sender, EventArgs e) { //frmMovimentosCAIXA frm = new frmMovimentosCAIXA(); //frm.ShowDialog(); ButtonClickedEventArgs a = new ButtonClickedEventArgs() { ActionName = "SHOW_CAIXA", ButtonText = button3.Text }; OnButtonClicked?.Invoke(this, a); }
/// <summary> /// /// </summary> /// <param name="context"></param> public override void OnAttach(Context context) { base.OnAttach(context); _activity = context as MainActivity; try { _buttonOkClicked = (OnButtonClicked)context; } catch (NotImplementedException e) { throw new Exception(e.Message + " - Must implement OnButtonClicked"); } }
private void button4_Click(object sender, EventArgs e) { if (MessageBox.Show("Tem a Certeza que deseja sair?", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { ButtonClickedEventArgs a = new ButtonClickedEventArgs() { ActionName = "EXIT", ButtonText = button1.Text }; OnButtonClicked?.Invoke(this, a); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGerirCategoria_Click(object sender, EventArgs e) { ButtonClickedEventArgs args = new ButtonClickedEventArgs() { ActionName = "MANAGE_CATEGORIAS", ButtonText = btnGerirCategoria.Text, Data = new Dictionary <string, object>() { { "TipoMovimentoId", cboTipoMovimento.SelectedValue } } }; OnButtonClicked.Invoke(this, args); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGerirBeneficiario_Click(object sender, EventArgs e) { ButtonClickedEventArgs args = new ButtonClickedEventArgs() { ActionName = "MANAGE_BENEFICIARIOS", ButtonText = btnGerirBeneficiario.Text, Data = new Dictionary <string, object>() { { "EntidadeId", cboEntidade.SelectedValue } } }; OnButtonClicked.Invoke(this, args); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCancelar_Click(object sender, EventArgs e) { if (MessageBox.Show("Tem a Certeza que deseja sair?", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { ButtonClickedEventArgs args = new ButtonClickedEventArgs() { ActionName = "EXIT", ButtonText = btnCancelar.Text, Data = null }; OnButtonClicked.Invoke(this, args); } }
// // Methods // public object AddButton(string text, OnButtonClicked eventCallback) { if (eventCallback != null && !string.IsNullOrEmpty(text)) { UIButton uIButton = this.m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(kButtonTemplate)) as UIButton; uIButton.text = text; uIButton.eventClick += delegate(UIComponent c, UIMouseEventParameter sel) { eventCallback(); }; return(uIButton); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create button with no name or no event"); return(null); }
void Button(UIHelper group, string text, string tooltip, OnButtonClicked action) { try { UIButton button = group.AddButton(text, action) as UIButton; button.textScale = 0.875f; if (tooltip != null) { button.tooltip = tooltip; } } catch (Exception e) { UnityEngine.Debug.LogException(e); } }
internal void InitGamePadHandlers() { _gamePadHandlers = new GamePadHandler[MaxGamePads]; for (int i = 0; i < MaxGamePads; i++) { var handle = _gamePadHandlers[i] = new GamePadHandler(i); // Redirect Events. handle.OnConnection += () => OnConnection?.Invoke(handle); handle.OnDisconnect += () => OnDisconnected?.Invoke(handle); handle.OnButtonDown += (button, value) => OnButtonDown?.Invoke(handle, button, value); handle.OnButtonUp += (button, value) => OnButtonUp?.Invoke(handle, button, value); handle.OnButtonPressed += (button, value) => OnButtonPressed?.Invoke(handle, button, value); handle.OnButtonClicked += (button, value) => OnButtonClicked?.Invoke(handle, button, value); handle.OnButtonReleased += (button, value) => OnButtonReleased?.Invoke(handle, button, value); } }
public static UIButton AddButton(UIComponent parent, string text, OnButtonClicked eventCallback) { if (eventCallback != null && !string.IsNullOrEmpty(text)) { var uIButton = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kButtonTemplate)) as UIButton; uIButton.transform.localScale = Vector3.one; uIButton.text = text; uIButton.eventClick += delegate(UIComponent c, UIMouseEventParameter sel) { eventCallback(); }; uIButton.forceZOrder = 999999999; uIButton.canFocus = false; return(uIButton); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create button with no name or no event"); return(null); }
public object AddButton(string text, OnButtonClicked eventCallback) { bool flag = eventCallback != null && !string.IsNullOrEmpty(text); object result; if (flag) { UIButton uIButton = this.m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kButtonTemplate)) as UIButton; uIButton.text = text; uIButton.eventClick += delegate(UIComponent c, UIMouseEventParameter sel) { eventCallback(); }; result = uIButton; } else { DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create button with no name or no event"); result = null; } return(result); }
public void Draw() { GUI.color = _color; if (string.IsNullOrEmpty(_text)) { if (GUI.Button(_rect, string.Empty)) { if (OnButtonClicked != null) { OnButtonClicked.Invoke(_isEnabled); } } } else { if (GUI.Button(_rect, _text)) { ButtonClick(); } } }
void Awake() { UIManager uIManager = transform.root.GetComponent <UIManager>(); foreach (var btn in _expandButtons) { btn.GetComponent <Button>().onClick.AddListener(() => ExpandPanel(btn)); btn.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => ExpandPanel(btn)); btn.onExpanded += HideControls; btn.onClosed += DisplayControls; } UnityAction saveFile = () => { AppManager.Instance.SaveFile(_currentFile, _inputField.text); uIManager.OpenMainMenu(); }; _saveButton.onClick.AddListener(saveFile); _saveButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(saveFile); _closeButton.onClick.AddListener(() => uIManager.OpenMainMenu()); _closeButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => uIManager.OpenMainMenu()); _backspaceButton.onClick.AddListener(() => RemoveLastSymbol()); _backspaceButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => RemoveLastSymbol()); _enterButton.onClick.AddListener(() => InputEnterLine()); _enterButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => InputEnterLine()); _spaceButton.onClick.AddListener(() => InputSpaceSymbol()); _spaceButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => InputSpaceSymbol()); _symbolModeButton.onClick.AddListener(() => SwitchInputMode()); _symbolModeButton.GetComponentInChildren <NeuroTag>().onTriggered.AddListener(() => SwitchInputMode()); onButtonClicked += FocusOnInputPanel; }
private void InitAssetSelectionTab() { UIHelperExtension assetSelectionTabContainer = createNewAsteriskTab(Locale.Get("TLM_CITY_ASSETS_SELECTION")); m_defaultAssets = assetSelectionTabContainer.AddTextList(Locale.Get("TLM_DEFAULT_ASSETS"), new Dictionary <string, string>(), delegate(string idx) { }, 340, 250); m_prefixAssets = assetSelectionTabContainer.AddTextList(Locale.Get("TLM_ASSETS_FOR_PREFIX"), new Dictionary <string, string>(), delegate(string idx) { }, 340, 250); foreach (Transform t in ((UIPanel)assetSelectionTabContainer.self).transform) { var panel = t.gameObject.GetComponent <UIPanel>(); if (panel) { panel.width = 340; } } m_prefixAssets.root.backgroundSprite = "EmptySprite"; m_prefixAssets.root.color = Color.white; m_prefixAssets.root.width = 340; m_defaultAssets.root.backgroundSprite = "EmptySprite"; m_defaultAssets.root.width = 340; assetSelectionTabContainer.AddSpace(10); m_prefixAssets.EventOnSelect += M_defaultAssets_eventOnSelect; m_defaultAssets.EventOnSelect += M_defaultAssets_eventOnSelect; OnButtonClicked reload = delegate { reloadAssetsList(m_prefixSelection.selectedIndex); }; assetSelectionTabContainer.AddButton(Locale.Get("TLM_ADD"), delegate { if (m_defaultAssets.unselected) { return; } var selected = m_defaultAssets.selectedItem; if (selected == null || selected.Equals(default(string))) { return; } addAssetToPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1), selected); reload(); }); assetSelectionTabContainer.AddButton(Locale.Get("TLM_REMOVE"), delegate { if (m_prefixAssets.unselected) { return; } var selected = m_prefixAssets.selectedItem; if (selected == null || selected.Equals(default(string))) { return; } removeAssetFromPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1), selected); reload(); }); assetSelectionTabContainer.AddButton(Locale.Get("TLM_REMOVE_ALL"), delegate { removeAllAssetsFromPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1)); reload(); }); assetSelectionTabContainer.AddButton(Locale.Get("TLM_RELOAD"), delegate { reload(); }); assetSelectionTabContainer.AddSpace(5); setPreviewWindow(assetSelectionTabContainer); }
//Initing Button Actions private void Init(Action <bool> p) { try { GiveUIObject <Button>(Strings.Ranked, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _rankedButton = Sccss; _rankedButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Ranked, (clbk) => { if (clbk) { } else { Debug.LogError("Failed To do action"); } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.FreeRide, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _freeRideButton = Sccss; _freeRideButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.FreeRide, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.MultiPlayer, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _multiPlayerButton = Sccss; _multiPlayerButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.MultiPlayer, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Quit, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _quitButton = Sccss; _quitButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Quit, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Settings, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _settingsButton = Sccss; _settingsButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Open, (clbk) => { if (clbk) { } else { } }, gobjects.SettingsWindow); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Garage, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _garageButton = Sccss; _garageButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Garage, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Profile, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _profileButton = Sccss; _profileButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Profile, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Rating, Strings.BackgroundImage, (Sccss) => { if (Sccss) { _ratingButton = Sccss; _ratingButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Rating, (clbk) => { if (clbk) { } else { } }); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); GiveUIObject <Button>(Strings.Close, Strings.SettingsWindow, (Sccss) => { if (Sccss) { _settingsCloseButton = Sccss; _settingsCloseButton.onClick.AddListener(delegate { OnButtonClicked?.Invoke(ButtonActionEnum.Close, (clbk) => { if (clbk) { } else { } }, gobjects.SettingsWindow); }); } else { throw new GameCustomException(ErrorStrings.CannotFindGameObject); } }); } catch (GameCustomException) { Debug.LogError("Failed"); } catch (Exception) { Debug.LogError("Failed"); } }
public void OnButtonClickedCallback(OnButtonClicked fnc) { onButtonClicked = fnc; }
void CreateButton(String label, OnButtonClicked onClicked) { i++; if( GUI.Button(new Rect(X_POSITION_REFERENCE, i * Y_POSITION_REFERENCE, BUTTON_WIDTH, BUTTON_HEIGHT), label) ) { onClicked(); } }