Closed Updownquark closed 10 years ago
The error preventing this from working says a widget already accepts an attribute named "role". I foresaw this when working on templates (#32, here) a while back, but didn't address it at the time. The problem is that I'm using a border, another templated widget, with specified content inside the template for text field. So to specify the content of the border from outside the template, there has to be a role for the text field template, and a role for the border. Right now the attribute manager only allows one attribute of a given name.
The correct way to resolve this is to allow multiple attributes with the same name, and define well which one gets assigned if an attribute is specified by name (as opposed to by the attribute object itself). I suspect the attribute last accepted should be the one specifiable by name, but I need to make sure.
The other problem is that in order to specify styles for the internals of the text field (corner radius of the border should be zero, the background color of the label should be white), I have to resort to using groups. As I wrote in #38, I think I should be able to specify styles for the attach points inside a template.
Text field now shows up. I had it showing the border with white inside (margin spacing between the border and the white). But after I moved the white style to the border pane, the border doesn't show up anymore. The border texture code is being called, so I don't know why it's not working.
Text field now renders correctly. At least 4 more things to do:
The next thing to do is design the input mechanism. Think about allowing some of this to be specified in an attribute so that the feel of the widget can be switched out.
Not leaving it in a great state here. :-( There's still parsing errors with the style sheets even though I thought I'd fixed them. Gotta fix them before anything else has a chance to work. That said I did some good work today, even though text selection still isn't working. To do now:
So number 1 in the comment above seems to be done. I was correct that the selection doesn't work right for text fields, and it does seem to be offset by the distance from the edge of the text field to the edge of the text.
Looks like the text field is where I intended it to be in that last big comment. Still a few things keep it from being what it should be though:
I did not mean to close this.
The above commit should say that cut was also implemented.
The cursor blink sort of works correctly now. But there are some strange rendering issues. With the fixes I've done today the rendering issues have bled over into the document in general, so that MUIS looks much worse than it did yesterday. But I'm confident I've only exposed problems that have been here for a while and need to be fixed immediately.
The text field looks a bit better, but the highlight color flashes between the correct shade of blue and a washed-out shade. There's double-rendering of the document happening (the text selection change causes the text element to completely re-render and causes the text field to re-render the previous cursor area (this is the latest rendering fix that fixed little black pixels when selection changed), so these are not combined in the event queue because the cursor stretches out of the bounds of the text element. Not sure if I should try to make an attempt to combine these. Seems like I should later), but this should not cause display issues. This is the next thing to investigate.
I have fixed the highlight color flashing issue. Turns out it was a problem with ArrayUtils.cachingIterable in prisms. Referring to my comment a month ago, I'm not noticing strange rendering issues in the document in general now. Guess I'll have to be on the lookout for this.
2 things to investigate now. There's obviously a bug because the border should see its styles. The second is that I don't understand at the moment why I can't put the border and the cursor overlay right under the body, but when I tried to do that MUIS gave me an intelligible error saying that was illegal.
TextField looks great now. The next thing is to support a length attribute, which sets the preferred width of the field (in units of characters). I can't decide whether the default value of length should be 30ish or if it should be unset, meaning the text field prefers to grow with its contents. Along with this, I need to implement the ability to navigate large amounts of text within a small text field, using keyboard navigation (arrows, end, home, etc.). The cursor location must always be visible in the text field and text that falls off to the left and right must not be visible.
Good day! The design work and implementation for basic text fields is almost done, barring conceptual problems that show up later. There's an exception for one of the last features, filling a text box with more text than it can display. There's only one more feature I can think of that the basic (1-line) text box needs, and that's Home and End key support (with and without shift held).
Text field looks better and better. There are a few issues, and then some features to add: The issues:
The features:
Hooking up to models (text fields and labels) is next.
I need to be able to change the document in a text element so a MUIS model may specify an actual document for a text widget. This would allow the model to insert a model that does different kinds of formatting. Possibly the use case for this is not likely and can be done other ways. Replacing the document is not trivial though. Listeners may have already been added to the document which would need to be transferred to the new document, but documents coming in from models may have listeners on them that MUIS did not add. It's sticky.
I need to test the latest code before I really call it good, but TextField is pretty good now. I'm gonna work on a nice demo of the existing functionality for a while before I add more features.
Just realized I need to fix TextField to not apply user changes to the model until focus lost or enter is pressed. Perhaps this could be an option.
Been thinking more about this. I think rich editing will be done by a more complicated widget than this. Probably one with lots of buttons and other widgets to facilitate creating more complex documents. I'm not sure if formatting and validating should be done in this class or not (most likely not), but regardless that will be a separate task.
So the things that need to be done before this can be closed are:
Multi-line support is in and text field looks pretty good. I mentioned in the comment just above that I wanted to batch events from AbstractSelectableDocumentModel. I tried this last night and it seemed like it messed some things up. My solution seemed simple and I don't understand why it didn't work. It's very possible that this can be done and it's also possible there's some conceptual problem with it. In any case, it doesn't affect text field's functionality to not be there. I'm sure to find bugs in it in the future, but I declare that the development of text field is done!!!
Have the option of multiple lines instead of a separate TextArea widget (?)
Also create a ValidatedTextField widget. This widget should have modes for unset, incomplete, invalid, validation pending, and valid. Should have a simple mechanism for specifying styles for these different modes. Default would be a red fuzzy border for unset, incomplete, and invalid (possibly slightly different between them), an animated progress-like border for pending, and fading green fuzzy border for valid, finishing with an inconspicuous visual cue that the input is validated.