mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #125] Changing Flex proportions #97
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @benweidig on GitHub (May 26, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/125
Hi,
in my app I want to change the Flex proprotions with the keyboard. So far I need to rebuild the complete Flex with the new proportion, because the flexItem array is private.
First I thought about just building a modified Flex exposing the necessary fields, but Box doesn't expose focus, so I needed to copy/paste Box, too.
What are your opinions on how to solve this? Rebuild the Flex every time, or extend Flex to expose the flexItem array in a non-breaking way? Or did I miss something?
@rivo commented on GitHub (Jun 7, 2018):
Sorry for the late reply. You didn't miss something, it didn't exist. I've added a new function
ResizeItem()toFlexwhich should do what you're trying to do. Let me know if this works for you.@benweidig commented on GitHub (Jun 9, 2018):
Thx for the update, but the code isn't working as intended.
The
itemprovided byrangeis not pass-by-reference, it's pass-by-value. Only accessing an array by index is pass-by-reference. And to save it in a new variable we need to access it with&.Proposed fix:
@rivo commented on GitHub (Jun 9, 2018):
Good point. Actually, I think the
itemsslice should be a slice of*flexItem's anyway. (Not sure why I didn't do it this way but this was one of the very early types so maybe it grew over time.)The latest commit should have fixed it. Please let me know if it works for you now.