int main(void) { GWindow window = newGWindow(320, 240); GButton button = newGButton("button"); setActionCommand( button, "check" ); addToRegion(window, button, "SOUTH"); while( true ) { GActionEvent event = waitForEvent( ACTION_EVENT ); if( getEventType(event) == WINDOW_CLOSED ) { break; } else if( strcmp( getActionCommand(event) , "click") == 0 ) { printf("button was clicked\n"); } } closeGWindow(window); return 0; }
int main(void) { // instantiate window GWindow window = newGWindow(320, 240); // instantiate button GButton button = newGButton("Button"); setActionCommand(button, "click"); // add button to southern region of window addToRegion(window, button, "SOUTH"); // listen for events while (true) { // wait for event GActionEvent event = waitForEvent(ACTION_EVENT); // if window was closed if (getEventType(event) == WINDOW_CLOSED) { break; } // if action command is "click" if (strcmp(getActionCommand(event), "click") == 0) { printf("button was clicked\n"); } } // that's all folks closeGWindow(window); return 0; }