-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widgets/text area #4995
base: develop
Are you sure you want to change the base?
Widgets/text area #4995
Conversation
|
||
self:addviews{ | ||
TextAreaContent{ | ||
view_id='text_area', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think other widgets leave out the view_id
so that the caller can specify their own and then access their elements internally like self.subviews[element_index]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improved
function TextArea:getText() | ||
return self.subviews.text_area.text | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we expose a setText
method as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make it so that if you call setText(text)
and then press CTRL-Z, it will revert to the text before the setText
call? (If it's already working like that for you, let me know, I might just need to re-pull)
Edit: I repulled just to make sure so I didn't waste your time and confirmed that it's not working this way on the latest update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mixed feelings about it, can you present a usecase where it would be useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The situation where this came up for me is with this UI in a script I've been working on:
I'm using this to be able to quickly add notes to individual units. Once I no longer need the note for the unit, I'll clear it out with ALT+C. I know I could CTRL+A/backspace to clear all but I also wanted to provide a shortcut to clear the notes with a single hotkey press (I had this before while using an EditField here and still find it handy).
If a user ever did ALT+C by accident here, ideally they could CTRL+Z it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I would additionally expose clearHistory
function for cases where it would be a required behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
TextArea = defclass(TextArea, Panel) | ||
|
||
TextArea.ATTRS{ | ||
init_text = '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to switch this to text
instead of init_text
? It feels like text
might align more closely with the API of other widgets like EditField
, Label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid it will consfuse users and they will treat it as writeable property - where it is not. they need to to use :setText(...)
509a0c1
to
83a9a19
Compare
I really appreciate your work on all of this stuff! You really went all out with this widget and the result is fantastic. Journal is sooo good and it's awesome that every other script will have such a great textarea to work with. I have been looking forward to this PR 😄 |
This MR introduce
TextArea
widget.This widgets is already in use in
gui/journal
and cominggui/notes
tools.Its provide much better support for text manipultation than TextField do.
Scripts journal has been migrated here:
DFHack/scripts#1327