Spec Text Emphasis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Spec Text Emphasis

Sean P. DeNigris
Administrator
Is there a way to change the emphasis of Spec text (TextModel/TextInputModel, or even LabelModel - I would trade edit-ability for styling)?

The following successfully added the attribute to the text, but it didn't display in Spec:
    checkbox whenActivatedDo: [ self textModel text: (self textModel text addAttribute: TextEmphasis struckOut) ].

Thanks!
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Peter Uhnak
On Thu, Sep 01, 2016 at 09:18:47PM -0700, Sean P. DeNigris wrote:
> Is there a way to change the emphasis of Spec text (TextModel/TextInputModel,
> or even LabelModel - I would trade edit-ability for styling)?

LabelModel has #emphasis:

LabelModel new
        emphasis: #(bold);
        label: 'bold';
        openWithSpec

TextModel accepts Text:

TextModel new
        text: 'bold' asText allBold, (' red' asText makeAllColor: Color red);
        openWithSpec

TextInputFieldModel will most likely require #whenBuiltDo: and Morphic hacking.

Peter

Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Sean P. DeNigris
Administrator
Peter Uhnak wrote
TextModel accepts Text:
Thanks for the sanity check. I realized where I was going wrong. There must be some sort of guard inside TextModel that no-ops if the string is the same, so changing the text works:
    tm text: ((tm text allButLast) asText addAttribute: TextEmphasis struckOut)
but only adding an attribute does nothing:
    tm text: (tm text asText addAttribute: TextEmphasis struckOut)

Since attributes are an allowed part of the content, seems like a bug, no?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Sean P. DeNigris
Administrator
In reply to this post by Peter Uhnak
Peter Uhnak wrote
LabelModel has #emphasis:
Another apparent bug:
    LabelModel new
        emphasis: #(struck); <--- doesn't work. It accepts #struck as a valid option, but does not strike the text
        label: 'struck';
        openWithSpec
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Sean P. DeNigris
Administrator
In reply to this post by Peter Uhnak
<frustrated />

Peter Uhnak wrote
TextInputFieldModel will most likely require #whenBuiltDo: and Morphic hacking.
That is unfortunate. As a subclass, and conceptually in the model, it should do everything that TextModel does - and more!

Since LabelModel and TextInputFieldModel have failed, it looks like the best I can do currently with Spec is to use TextModel, whose scroll bar is inappropriate in this context. Any way to hide it?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Nicolai Hess-3-2
In reply to this post by Sean P. DeNigris


2016-09-02 15:29 GMT+02:00 Sean P. DeNigris <[hidden email]>:
Peter Uhnak wrote
> LabelModel has #emphasis:

Another apparent bug:
    LabelModel new
        emphasis: #(struck); <--- doesn't work. It accepts #struck as a
valid option, but does not strike the text
        label: 'struck';
        openWithSpec


I think it sould work like that, it works for italic
 LabelModel new
        emphasis: #(italic);
        label: 'italic?';
        openWithSpec

somehow, "struc" should be 8 not 16, I don't know where or when this changed.
 


-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Spec-Text-Emphasis-tp4913688p4913799.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Peter Uhnak
In reply to this post by Sean P. DeNigris
On Fri, Sep 02, 2016 at 06:40:01AM -0700, Sean P. DeNigris wrote:
> <frustrated />
>
>
> Peter Uhnak wrote
> > TextInputFieldModel will most likely require #whenBuiltDo: and Morphic
> > hacking.
>
> That is unfortunate. As a subclass, and conceptually in the model, it should
> do everything that TextModel does - and more!

Unfortunately it's a subclass, not a subtype.
In other words it's implementation reuse. There are many (also conceptual) differences between the two.




>
> Since LabelModel and TextInputFieldModel have failed, it looks like the best
> I can do currently with Spec is to use TextModel, whose scroll bar is
> inappropriate in this context. Any way to hide it?

You can also talk directly to the morph... whenBuiltDo: [:adapter | adapter widget something something ]

>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Spec-Text-Emphasis-tp4913688p4913802.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Sean P. DeNigris
Administrator
In reply to this post by Sean P. DeNigris
Sean P. DeNigris wrote
There must be some sort of guard inside TextModel that no-ops if the string is the same, so changing the text works:
This seems to be true of plain TextMorphs as well.

More disturbingly, it seems that LabelMorphs *silently throw away any emphasis that isn't bold or italics* due to the implementation of LogicalFont>>#emphasized:. Argh...

On another note, bare TextMorphs adapted for Spec successfully displayed the strikethrough, but I can't for the life of me figure out how to get them #hResizing: #spaceFill! I tried both:
                newRow: [:row | row
                                newColumn: [ :col | col add: #checkbox ] width: 25;
                                newColumn: [ :col | col add: #textField ] ] height: 35;
and without the columns:
                newRow: [:row | row
                                add: #checkbox width: 25;
                                add: #textField ] height: 35;

I've run out of time for this project. Thank you for your help.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Spec Text Emphasis

Nicolai Hess-3-2
In reply to this post by Nicolai Hess-3-2


2016-09-02 15:56 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-09-02 15:29 GMT+02:00 Sean P. DeNigris <[hidden email]>:
Peter Uhnak wrote
> LabelModel has #emphasis:

Another apparent bug:
    LabelModel new
        emphasis: #(struck); <--- doesn't work. It accepts #struck as a
valid option, but does not strike the text
        label: 'struck';
        openWithSpec


I think it sould work like that, it works for italic
 LabelModel new
        emphasis: #(italic);
        label: 'italic?';
        openWithSpec

somehow, "struc" should be 8 not 16, I don't know where or when this changed.


see bug report 19067 Wrong emphasis code for struck and narrow


 


-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Spec-Text-Emphasis-tp4913688p4913799.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.