Getting a user input string using Morphs

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

Getting a user input string using Morphs

Jigyasa Grover
Hi !

I am new to Pharo and am currently working on making an Offline Text Search Application.
I plan to use Morphs to make a nice GUI.
Initially, I had thought of using TextMorphForEditView to get an input string from the user, but I feel this is not giving the desired functionality.
Would be great if anyone could suggest a way to get input string from the user in the same window using an 'input text box' interface element.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

HilaireFernandes
You can try and explore something like:

*|| m ||**
**|m := StringMorph contents: 'Edit me'.|**
**|m openInWorld.|**
**|m launchMiniEditor: ActiveEvent|*

Hilaire

Le 09/06/2015 15:25, Jigyasa Grover a écrit :
> Hi !
>
> I am new to Pharo and am currently working on making an Offline Text Search
> Application.
> I plan to use Morphs to make a nice GUI.


--
Dr. Geo
http://drgeo.eu
http://google.com/+DrgeoEu



Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

Jigyasa Grover
Thanks HilaireFernandes
But am afraid it gives the error " Message Not Understood: receiver of 'hand' is nil " .
Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

HilaireFernandes
Le 09/06/2015 18:04, Jigyasa Grover a écrit :

> Thanks HilaireFernandes
> But am afraid it gives the error " Message Not Understood: receiver of
> 'hand' is nil " .
>
>
>
>
> --
> View this message in context: http://forum.world.st/Getting-a-user-input-string-using-Morphs-tp4831121p4831231.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
I guess you tried with Pharo4.0.
I did with 3.0

--
Dr. Geo
http://drgeo.eu
http://google.com/+DrgeoEu



Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

Jigyasa Grover
Yes
I am currently developing it in Pharo 4.0

Thanks :)
Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

HilaireFernandes
The needed change for this low level access to morph is probably a small
one, related to ActiveHand, but I have not yet move to 4.0.
In the other hand, you may want to use higher level approaches suggested
by Pharo fellows.

Hilaire

Le 10/06/2015 09:20, Jigyasa Grover a écrit :
> Yes
> I am currently developing it in Pharo 4.0
>
> Thanks :)
>
>


--
Dr. Geo
http://drgeo.eu
http://google.com/+DrgeoEu



Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

Jigyasa Grover
Yep, still exploring ...

Thanks
Jigyasa
Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

stepharo
In reply to this post by HilaireFernandes
Yes hilaire ActiveHand as a global is a "bad concept"
In blog there is not globals anymore :)

Le 10/6/15 10:54, Hilaire a écrit :

> The needed change for this low level access to morph is probably a small
> one, related to ActiveHand, but I have not yet move to 4.0.
> In the other hand, you may want to use higher level approaches suggested
> by Pharo fellows.
>
> Hilaire
>
> Le 10/06/2015 09:20, Jigyasa Grover a écrit :
>> Yes
>> I am currently developing it in Pharo 4.0
>>
>> Thanks :)
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Getting a user input string using Morphs

Stephan Eggermont-3
In reply to this post by HilaireFernandes
On 09-06-15 20:10, Hilaire wrote:
> I guess you tried with Pharo4.0.
> I did with 3.0

It is a difference between Workspace and GTPlayground.
In GTPlayground, ActiveEvent is nil, so it doesn't work.
In Workspace it works.

launchMiniEditor: evt

        | textMorph |
        hasFocus := true.  "Really only means edit in progress for this morph"
        textMorph := StringMorphEditor new contentsAsIs: contents.
        textMorph beAllFont: self fontToUse.
        textMorph bounds: (self bounds expandBy: 0@2).
        self addMorphFront: textMorph.
        evt hand newKeyboardFocus: textMorph.
        textMorph editor selectFrom: 1 to: textMorph paragraph text string size

replace evt hand by ActiveHand to make it work in GTPlayground.

Stephan