[PR #208] [CLOSED] change: provide drop-down option text and index as args to selection callback when using (*DropDown).AddOption() #878

Closed
opened 2026-03-04 01:08:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/208
Author: @ardnew
Created: 12/18/2018
Status: Closed

Base: masterHead: dropdown-addoption


📝 Commits (7)

  • 334dfbe Adding accept() callback support for all relevant input changes in an InputField
  • 739b305 Merge https://github.com/rivo/tview
  • a207e47 change: provide drop-down option text and index as args to selection callback when using (*DropDown).AddOption()
  • 4dafc38 change: provide drop-down option text and index as args to selection callback when using (*DropDown).AddOption()
  • 75c14a5 Merge remote-tracking branch 'upstream/master'
  • 80eeae3 Merge branch 'dropdown-addoption' of https://github.com/ardnew/tview
  • fafd074 change: implemented view tracking in List for more natural navigation

📊 Changes

3 files changed (+62 additions, -31 deletions)

View changed files

📝 dropdown.go (+17 -13)
📝 inputfield.go (+4 -2)
📝 list.go (+41 -16)

📄 Description

rivo/tview#206

this change will break backwards compatibility for anyone using (*DropDown).AddOption() as its formal signature is changed. but i'm not convinced it's worth preserving the original and implementing this under a different name as the functionality is basically identical.

also I wasn't sure why (*DropDown).SetOptions() had the anon function in the body of its for-loop, so I took the liberty of removing it because it was a little confusing that variable identifiers were being reused at different scopes.

but even if you want to restore it, one of the variables (text I believe) was being captured under the closure even though it was passed in via argument! so that needs to be changed regardless.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/208 **Author:** [@ardnew](https://github.com/ardnew) **Created:** 12/18/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `dropdown-addoption` --- ### 📝 Commits (7) - [`334dfbe`](https://github.com/rivo/tview/commit/334dfbe7eefba4e1279cf0e5f537846125872d0d) Adding accept() callback support for all relevant input changes in an InputField - [`739b305`](https://github.com/rivo/tview/commit/739b305ec7c56c1cc23e83b35abf37133fe3328d) Merge https://github.com/rivo/tview - [`a207e47`](https://github.com/rivo/tview/commit/a207e47fb4e271568e81c0d5e225a9d1b39a6673) change: provide drop-down option text and index as args to selection callback when using (*DropDown).AddOption() - [`4dafc38`](https://github.com/rivo/tview/commit/4dafc3875862887b907ddf19234b2074271072ae) change: provide drop-down option text and index as args to selection callback when using (*DropDown).AddOption() - [`75c14a5`](https://github.com/rivo/tview/commit/75c14a56440bb2fb9d5c60b99298c5d14b089205) Merge remote-tracking branch 'upstream/master' - [`80eeae3`](https://github.com/rivo/tview/commit/80eeae329d51842ca86cfcc4a6a232a49ee8de00) Merge branch 'dropdown-addoption' of https://github.com/ardnew/tview - [`fafd074`](https://github.com/rivo/tview/commit/fafd0745f0b6154685ed7ab4342e60c18d1b44ea) change: implemented view tracking in List for more natural navigation ### 📊 Changes **3 files changed** (+62 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `dropdown.go` (+17 -13) 📝 `inputfield.go` (+4 -2) 📝 `list.go` (+41 -16) </details> ### 📄 Description rivo/tview#206 this change will break backwards compatibility for anyone using `(*DropDown).AddOption()` as its formal signature is changed. but i'm not convinced it's worth preserving the original and implementing this under a different name as the functionality is basically identical. also I wasn't sure why `(*DropDown).SetOptions()` had the anon function in the body of its for-loop, so I took the liberty of removing it because it was a little confusing that variable identifiers were being reused at different scopes. but even if you want to restore it, one of the variables (`text` I believe) was being captured under the closure even though it was passed in via argument! so that needs to be changed regardless. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:08:22 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#878
No description provided.