What am I doing wrong with the TButtonHolder?

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

What am I doing wrong with the TButtonHolder?

Marcus Lunzenauer-3
Hi,

I experimented with the TButtonHolder class but could not get it
working. I just added two Buttons to a ButtonHolder which I added to my
SimpleDemoWorld space. When I drag it from the parts bin, the red screen
just stays there.

From SimpleDemoWorld #initialize I called my new method #makeButton:
which contains:

makeButton: space
        | button tframe button2 tframe2 holder matRectNorm |

        matRectNorm := TMaterial new.
        matRectNorm ambientColor: #(0.8 0.8 0.8 0.5).
        matRectNorm diffuseColor: #(0.8 0.8 0.8 0.5).

        tframe := TRectangle new.
        tframe material: matRectNorm.
        button := TButton new initializeWithFrame: tframe.
  button persist: true.

        tframe2 := TRectangle new.
        tframe2 material: matRectNorm.
        button2 := TButton new initializeWithFrame: tframe2.
        button2 persist: true.

        holder := TButtonHolder new.
        holder translationX: 0 y: 0 z: 30.
        holder radioOn.
        holder addChild: button.
        holder addChild: button2.
        space addChild: holder.

What's wrong with my code?

Thanks a lot,
Marcus


P.S.: Heh. After typing smalltalk code several minutes, I continously
press command-s in my thunderbird ;-)
Reply | Threaded
Open this post in threaded view
|

Re: What am I doing wrong with the TButtonHolder?

KiranMutt
Probably I think you might have to creat Tweak based CPlayer user interface using CroquetHarness and then you would be able to add this button.
You can add this way for 3D objects like pyramids,cubes. But UI element has to go through Harness process.
 
May other Croquet experts can give a better reply.
 
- Kiran

 
On 5/27/07, Marcus Lunzenauer <[hidden email]> wrote:
Hi,

I experimented with the TButtonHolder class but could not get it
working. I just added two Buttons to a ButtonHolder which I added to my
SimpleDemoWorld space. When I drag it from the parts bin, the red screen
just stays there.

From SimpleDemoWorld #initialize I called my new method #makeButton:
which contains:

makeButton: space
       | button tframe button2 tframe2 holder matRectNorm |

       matRectNorm := TMaterial new.
       matRectNorm ambientColor: #(0.8 0.8 0.8 0.5).
       matRectNorm diffuseColor: #(0.8 0.8 0.8 0.5).

       tframe := TRectangle new.
       tframe material: matRectNorm.
       button := TButton new initializeWithFrame: tframe.
       button persist: true.

       tframe2 := TRectangle new.
       tframe2 material: matRectNorm.
       button2 := TButton new initializeWithFrame: tframe2.
       button2 persist: true.

       holder := TButtonHolder new.
       holder translationX: 0 y: 0 z: 30.
       holder radioOn.
       holder addChild: button.
       holder addChild: button2.
       space addChild: holder.

What's wrong with my code?

Thanks a lot,
Marcus


P.S.: Heh. After typing smalltalk code several minutes, I continously
press command-s in my thunderbird ;-)

Reply | Threaded
Open this post in threaded view
|

Re: What am I doing wrong with the TButtonHolder?

David A Smith
In reply to this post by Marcus Lunzenauer-3
Try

       holder addButton: button.
       holder addButton: button2.

not #addChild:....

DAS


Marcus Lunzenauer wrote:

> Hi,
>
> I experimented with the TButtonHolder class but could not get it
> working. I just added two Buttons to a ButtonHolder which I added to my
> SimpleDemoWorld space. When I drag it from the parts bin, the red screen
> just stays there.
>
> From SimpleDemoWorld #initialize I called my new method #makeButton:
> which contains:
>
> makeButton: space
> | button tframe button2 tframe2 holder matRectNorm |
>
> matRectNorm := TMaterial new.
> matRectNorm ambientColor: #(0.8 0.8 0.8 0.5).
> matRectNorm diffuseColor: #(0.8 0.8 0.8 0.5).
>
> tframe := TRectangle new.
> tframe material: matRectNorm.
> button := TButton new initializeWithFrame: tframe.
>   button persist: true.
>
> tframe2 := TRectangle new.
> tframe2 material: matRectNorm.
> button2 := TButton new initializeWithFrame: tframe2.
> button2 persist: true.
>
> holder := TButtonHolder new.
> holder translationX: 0 y: 0 z: 30.
> holder radioOn.
> holder addChild: button.
> holder addChild: button2.
> space addChild: holder.
>
> What's wrong with my code?
>
> Thanks a lot,
> Marcus
>
>
> P.S.: Heh. After typing smalltalk code several minutes, I continously
> press command-s in my thunderbird ;-)
>  

Reply | Threaded
Open this post in threaded view
|

Re: What am I doing wrong with the TButtonHolder?

Marcus Lunzenauer-3
Hi,

David A Smith wrote:
> Try
>
>       holder addButton: button.
>       holder addButton: button2.
>
> not #addChild:....

there is no method called #addButton: for class TButtonHolder.

After trying to solve it on my own, I found out why my example did not
work. Obviously a button has to have _two_ frames and not just one to be
usable as a radio button! So my code consists now of the following lines:

makeButton: space
| button tframe button2 tframe2 holder |

    tframe := TCube new.
  tframe2 := TSphere new.
  button := TButton new initializeSwitchWithFrame: tframe frame2: tframe2.
  button persist: true.


  tframe := TCube new.
  tframe2 := TSphere new.
  button2 := TButton new initializeSwitchWithFrame: tframe frame2: tframe2.
  button2 persist: true.


        holder := TButtonHolder new.
        holder translationX: 0 y: 0 z: -20.
  holder addChild: button.
  holder addChild: button2.
  holder radioOn.
  space addChild: holder.

This works like a charm until one wants to click on one of the buttons
which virtually freezes Croquet. After repeatedly typing Alt-. one gets
a "Method not found: selectedObject". This leads to the #radio: message
in class TButtonHolder where that message gets send. Unfortunately there
is no such method but after trying several minutes I ended up with:

ptr selection frame objectOwner

instead of

ptr selectedObject

This is obviously a bug in the Croquet SDK.


If one could get an account for the opencroquet wiki, I would like to
enhance the documentation of the classes while exploring the framework.

Regards, Marcus


P.S.: Is there a better way to debug a frozen Croquet morph instead of
repeatedly typing Alt-. ?