Write (rubric) text changes back to the object in GTInspector

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

Write (rubric) text changes back to the object in GTInspector

Torsten Bergmann
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?

Thanks
T.

Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Andrei Chis
Hi,

You can try this:

composite := GLMCompositePresentation new.
composite pharoPlayground
     title: 'Script';
     variableBindings: [ { #x -> 1. #y -> 2 } ].
composite
 openOn: 'x+y'.
   
For the moment only script presentations can have variables.

Btw  #pharoPlayground  and #rubricText will be deprecated in the latest version in favour of #pharoScript and #text

Cheers,
Andrei

On Fri, Oct 30, 2015 at 11:14 AM, Torsten Bergmann <[hidden email]> wrote:
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?

Thanks
T.

Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Nicolai Hess-3-2


2015-10-30 16:32 GMT+01:00 Andrei Chis <[hidden email]>:
Hi,

You can try this:

composite := GLMCompositePresentation new.
composite pharoPlayground
     title: 'Script';
     variableBindings: [ { #x -> 1. #y -> 2 } ].
composite
 openOn: 'x+y'.
   
For the moment only script presentations can have variables.

Btw  #pharoPlayground  and #rubricText will be deprecated in the latest version in favour of #pharoScript and #text

Cheers,
Andrei

On Fri, Oct 30, 2015 at 11:14 AM, Torsten Bergmann <[hidden email]> wrote:
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?


you can define an action on a port change:
onChangeOfPort:act:

| browser morph |
   morph := StringMorph new openInWorld.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
    browser := GLMTabulator new.
    browser
        row: #main.
    (browser transmit)
        to: #main;
        andShow: [ :a | a rubricText
            onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].

    ^ browser openOn:'type some text'

This will open a StringMorph and a GlamourBrowser.
If you change the text in the browser, it will change the contents of the string morph.



Thanks
T.


Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Andrei Chis

Ahh. I think I misunderstood your question :)

On Oct 30, 2015 11:48 AM, "Nicolai Hess" <[hidden email]> wrote:


2015-10-30 16:32 GMT+01:00 Andrei Chis <[hidden email]>:
Hi,

You can try this:

composite := GLMCompositePresentation new.
composite pharoPlayground
     title: 'Script';
     variableBindings: [ { #x -> 1. #y -> 2 } ].
composite
 openOn: 'x+y'.
   
For the moment only script presentations can have variables.

Btw  #pharoPlayground  and #rubricText will be deprecated in the latest version in favour of #pharoScript and #text

Cheers,
Andrei

On Fri, Oct 30, 2015 at 11:14 AM, Torsten Bergmann <[hidden email]> wrote:
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?


you can define an action on a port change:
onChangeOfPort:act:

| browser morph |
   morph := StringMorph new openInWorld.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
    browser := GLMTabulator new.
    browser
        row: #main.
    (browser transmit)
        to: #main;
        andShow: [ :a | a rubricText
            onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].

    ^ browser openOn:'type some text'

This will open a StringMorph and a GlamourBrowser.
If you change the text in the browser, it will change the contents of the string morph.



Thanks
T.


Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Torsten Bergmann
In reply to this post by Nicolai Hess-3-2
#onChangeOfPort:act: solved the problem. Thanks a lot!

BTW: would be cool if you both could join Pharo on Slack.

Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Andrei Chis


On Fri, Oct 30, 2015 at 12:07 PM, Torsten Bergmann <[hidden email]> wrote:
#onChangeOfPort:act: solved the problem. Thanks a lot!

BTW: would be cool if you both could join Pharo on Slack.

This and next week I'm travelling but afterwards I'll join
 

Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Andrei Chis
In reply to this post by Nicolai Hess-3-2
Cool example.
I slightly modified it and added it to the glamour examples :)

| browser morph |
   morph := StringMorph new.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
   browser := GLMTabulator new.
   browser
    row: #main;
row: #preview.
   browser transmit
      to: #main;
      andShow: [ :a | a text
        onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].
   browser transmit
to: #preview;
andShow: [ :a | a morph
title: 'Preview';
                       display: [ morph ] ].

  ^ browser openOn: 'some text'

On Fri, Oct 30, 2015 at 11:47 AM, Nicolai Hess <[hidden email]> wrote:


2015-10-30 16:32 GMT+01:00 Andrei Chis <[hidden email]>:
Hi,

You can try this:

composite := GLMCompositePresentation new.
composite pharoPlayground
     title: 'Script';
     variableBindings: [ { #x -> 1. #y -> 2 } ].
composite
 openOn: 'x+y'.
   
For the moment only script presentations can have variables.

Btw  #pharoPlayground  and #rubricText will be deprecated in the latest version in favour of #pharoScript and #text

Cheers,
Andrei

On Fri, Oct 30, 2015 at 11:14 AM, Torsten Bergmann <[hidden email]> wrote:
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?


you can define an action on a port change:
onChangeOfPort:act:

| browser morph |
   morph := StringMorph new openInWorld.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
    browser := GLMTabulator new.
    browser
        row: #main.
    (browser transmit)
        to: #main;
        andShow: [ :a | a rubricText
            onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].

    ^ browser openOn:'type some text'

This will open a StringMorph and a GlamourBrowser.
If you change the text in the browser, it will change the contents of the string morph.



Thanks
T.



Reply | Threaded
Open this post in threaded view
|

Re: Write (rubric) text changes back to the object in GTInspector

Nicolai Hess-3-2


2015-10-30 19:30 GMT+01:00 Andrei Chis <[hidden email]>:
Cool example.
I slightly modified it and added it to the glamour examples :)

| browser morph |
   morph := StringMorph new.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
   browser := GLMTabulator new.
   browser
    row: #main;
row: #preview.
   browser transmit
      to: #main;
      andShow: [ :a | a text
        onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].
   browser transmit
to: #preview;
andShow: [ :a | a morph
title: 'Preview';
                       display: [ morph ] ].

  ^ browser openOn: 'some text'


cool!

 
On Fri, Oct 30, 2015 at 11:47 AM, Nicolai Hess <[hidden email]> wrote:


2015-10-30 16:32 GMT+01:00 Andrei Chis <[hidden email]>:
Hi,

You can try this:

composite := GLMCompositePresentation new.
composite pharoPlayground
     title: 'Script';
     variableBindings: [ { #x -> 1. #y -> 2 } ].
composite
 openOn: 'x+y'.
   
For the moment only script presentations can have variables.

Btw  #pharoPlayground  and #rubricText will be deprecated in the latest version in favour of #pharoScript and #text

Cheers,
Andrei

On Fri, Oct 30, 2015 at 11:14 AM, Torsten Bergmann <[hidden email]> wrote:
Hi,

if one has an inspector extension that shows a textual iVar of an object
representing code (using #rubricText, #pharoMethod or  #pharoPlayground)
as in this example:

 gtInspectorSourceIn: composite
        <gtInspectorPresentationOrder: 30>
        ^ composite pharoMethod
                title: 'Source';
                smalltalkClass: [ self methodClass ];
                display: [ self getSource ];
                act: [ self browse ] icon: GLMUIThemeExtraIcons glamorousBrowse entitled: 'Browse'

What is the best/correct way to set the iVar when the text is typed so the
state of the iVar represents the lively editing in the inspector extension?

Or is there a way to realize this somehow with Glamour ports using the #text port?


you can define an action on a port change:
onChangeOfPort:act:

| browser morph |
   morph := StringMorph new openInWorld.
   morph font:(LogicalFont familyName: 'Source Code Pro' pointSize: 30).
    browser := GLMTabulator new.
    browser
        row: #main.
    (browser transmit)
        to: #main;
        andShow: [ :a | a rubricText
            onChangeOfPort: #text act: [ :text  |
            morph contents:text text] ].

    ^ browser openOn:'type some text'

This will open a StringMorph and a GlamourBrowser.
If you change the text in the browser, it will change the contents of the string morph.



Thanks
T.