How to programatically "click" a TGShutterItem?

Is there a way to cause a TGShutterItem to get “clicked” programatically - e.g. to become activated as though somebody actually clicked it? I tried calling the Clicked() method of the TGShutterItem’s button, but that did’nt do it.
Thanks ,
Ed Oltman

Hi Ed,

use the TFrame::SendMessage() method for that, like:

where “shutter_item_id” is the id of the TGShutterItem.

You can always use SendMessage() to talk to a ProcessMessage() method.

Cheers, Fons.[/code]

Hi Fons,

I have implemented the following method because of TGShutter:: SavePrimitive:

[code]void TGShutter::SetSelectedItem(TGShutterItem *item)
// Set item to be the currently open shutter item

fSelectedItem = item;
It might help.

Cheers, Ilka

I can use TFrame::SendMessage() sucessfully when called from a menu item message handler, but not from another TGShutterItem’s button click. In my application, each shutter item represents a “mode” of operation. If the user decides to switch from mode1 to mode2 before completing mode1, data might be lost. In this case, when shutter item2’s button is clicked, the user is alerted and offered an opportunity to cancel the (premature) mode switch and so shutter item 2’s button calls SendMessage() to the shutter item 1. However, nothing happens. Here’s some pseudocode: TGShutter *fShutter; TGButton *fShutterItem1Button,*fShutterItem2Button; . . fShutter = new TGShutter(...); TGShutterItem *item1 = new TGShutterItem(fShutter,"Mode 1",ITEM_1); ShutterItem1Button = (TGButton *)item->GetButton(); ShutterItem1Button->Connect("Clicked()","MyClass",this,"ShutterItem1Clicked()"); (add buttons to item1's frame) . . TGShutterItem *item2 = new TGShutterItem(fShutter,"Mode 2",ITEM_2); ShutterItem2Button = (TGButton *)item->GetButton(); ShutterItem2Button->Connect("Clicked()","MyClass",this,"ShutterItem2Clicked()"); (add buttons to item1's frame) . . void ShutterItem2Clicked() { // Switch to mode 2: . . //Uh-oh: user may loose data from mode 1: present a //TGMsgBox: OK (loose) or CANCEL (return to mode 1) if (CANCEL) SendMessage(fShutter,0,ITEM_1,0) //--> Nothing Happens! . . }

Is there a reason why this does’nt work? Thanks…


Hi Ed,
There is a new method TGShutter::SetSelectedItem(TGShutterItem *item)
that allows you to set programmatically the currently open shutter item.
The getter of selected item is there too. Please take the last cvs.

Cheers, Ilka