It would be nice to add a system dialog which presents the user with an “OK” and “Cancel” and returns bool true if user hits OK. Presently ofSystemErrorDialog is the closest to this but only has an OK button and returns nothing.

I have a partial implementation for this in a function ofSystemChoiceDialog that I’ve added to ofSystemUtils, but it’s only implemented for OSX (and probably in poor style). It’s basically a light modification of ofSystemErrorDialog.

bool ofSystemChoiceDialog(string choiceMessage){
    bool choice = true;
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSAlert *alertDialog = [NSAlert alertWithMessageText:[NSString stringWithUTF8String:choiceMessage.c_str()]
    [alertDialog addButtonWithTitle:@"Cancel"];
    NSInteger returnCode = [alertDialog runModal];

	// if Cancel was clicked, set choice to false
	if ( returnCode == NSAlertSecondButtonReturn )
		choice = false;
    [pool drain];
    return choice;
1 Like

A platform independent version of this function that would be quite helpful to have in the core. Does anyone know how to implement this for linux?

Implementing it on Linux depends if you have a windowing system available (e.g. X11). For Raspberry Pi there is no windowing system, so it would need to be a from-scratch implementation, with custom buttons, gui code, etc.

Fun. I’m assuming this applies to all ofSystemDialogues. That said I still think that this would be quite a nice addition to those ofSystemUtils. Perhaps if I have a bit of time in the next few days I could look into this. Anyone who has implemented this in linux with a windowing system that could point me in the right direction?

IVT has some very simple cross platform gui code if it’s helpful – at some point I ripped it out here but I remember @arturo saw some wonkiness:

1 Like