// // time: Wed Jul 30 09:48:24 1997 // // version: 3.1.1 (format), 3.1.4 (DX) // // // Begin MDF // MODULE GetEvents // CATEGORY Macros // DESCRIPTION extracts requested information from events // INPUT events; value list or field or string or string list; (no default); events output of SuperviseWindow // INPUT button_mask; value list or field or string or string list; (no default); or-ing of buttons requested: left=1, middle=2, right=4 // INPUT buttonstate; value list or field or string or string list; (no default); up=1, down=2, motion=3 // OUTPUT position; object; x,y position of event // OUTPUT event_occurred; object; whether or not a requested event occurred // End MDF // // comment: This macro, given an "events" input (the output // comment: of SuperviseWindow) and a user-specified // comment: mask for which kind of events are desired (which // comment: button, and button-up, down, or motion) outputs // comment: for any events matching the criteria the x,y position // comment: of the event. In addition, it outputs whether or not // comment: the specified type of event occurred, which is useful // comment: for switches and routes in the calling program. // comment: // comment: The input "button-mask" should be an "or-ring" of // comment: which buttons are desired, where left=1, middle=2, and // comment: right=4. For example, if you are interested in only left button events, then button-mask should be set to 1. If you are interested in both left and middle events, set button-mask to 3. If you are interested in only left and right button events, set button-mask to 5. // comment: // comment: The input "buttonstate" should be set to 1, 2, or 3, where // comment: 1=buttonup, 2=buttondown, and 3=buttonmotion. // workspace: width = 1005, height = 734 // layout: snap = 0, width = 50, height = 50, align = NN // macro GetEvents( events ,button_mask ,buttonstate ) -> ( position ,event_occurred ) { // // node Input[3]: x = 350, y = 14, inputs = 0, label = Input // parameter: position = 1, name = 'events', value = '(no default)', descriptive = 1, description = ' events output of SuperviseWindow', required = 0, visible = 1 // GetEvents_Input_3_out_1 = events; // // node Compute[6]: x = 405, y = 223, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "[$0.1, $0.2]" // expression: value = [a.1, a.2] // name[2]: value = a // GetEvents_Compute_6_out_1 = Compute( "[$0.1, $0.2]", GetEvents_Input_3_out_1 ) [instance: 6, cache: 1]; // // node Input[1]: x = 99, y = 10, inputs = 0, label = Input // parameter: position = 2, name = 'button_mask', value = '(no default)', descriptive = 1, description = ' or-ing of buttons requested: left=1, middle=2, right=4', required = 0, visible = 1 // GetEvents_Input_1_out_1 = button_mask; // // node Compute[7]: x = 112, y = 219, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "and($0.0, $1) ? 1 : 0" // expression: value = and(a.0, b) ? 1 : 0 // name[2]: value = a // name[3]: value = b // GetEvents_Compute_7_out_1 = Compute( "and($0.0, $1) ? 1 : 0", GetEvents_Input_3_out_1, GetEvents_Input_1_out_1 ) [instance: 7, cache: 1]; // // node Input[2]: x = 220, y = 8, inputs = 0, label = Input // parameter: position = 3, name = 'buttonstate', value = '(no default)', descriptive = 1, description = ' up=1, down=2, motion=3', required = 0, visible = 1 // GetEvents_Input_2_out_1 = buttonstate; // // node Compute[8]: x = 214, y = 222, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.3 == $1 ? 1 : 0" // expression: value = a.3 == b ? 1 : 0 // name[2]: value = a // name[3]: value = b // GetEvents_Compute_8_out_1 = Compute( "$0.3 == $1 ? 1 : 0", GetEvents_Input_3_out_1, GetEvents_Input_2_out_1 ) [instance: 8, cache: 1]; // // node Compute[9]: x = 158, y = 308, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0 && $1" // expression: value = a && b // name[2]: value = a // name[3]: value = b // GetEvents_Compute_9_out_1 = Compute( "$0 && $1", GetEvents_Compute_7_out_1, GetEvents_Compute_8_out_1 ) [instance: 9, cache: 1]; // // node Construct[3]: x = 321, y = 322, inputs = 4, label = Construct // GetEvents_Construct_3_out_1 = Construct( GetEvents_Compute_6_out_1, NULL, NULL, GetEvents_Compute_9_out_1 ) [instance: 3, cache: 1]; // // node Include[2]: x = 412, y = 391, inputs = 6, label = Include // input[2]: defaulting = 0, visible = 1, type = 5, value = 1.0 // input[3]: defaulting = 0, visible = 1, type = 5, value = 1.0 // input[6]: defaulting = 0, visible = 1, type = 3, value = 1 // GetEvents_Include_2_out_1 = Include( GetEvents_Construct_3_out_1, 1.0, 1.0, NULL, NULL, 1 ) [instance: 2, cache: 1]; // // node Extract[2]: x = 659, y = 489, inputs = 2, label = Extract // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions" // GetEvents_Extract_2_out_1 = Extract( GetEvents_Include_2_out_1, "positions" ) [instance: 2, cache: 1]; // // node Compute[10]: x = 630, y = 561, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "int($0)" // expression: value = int(a) // name[2]: value = a // GetEvents_Compute_10_out_1 = Compute( "int($0)", GetEvents_Extract_2_out_1 ) [instance: 10, cache: 1]; // // node Inquire[2]: x = 431, y = 107, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "is null + 1" // GetEvents_Inquire_2_out_1 = Inquire( GetEvents_Input_3_out_1, "is null + 1", NULL ) [instance: 2, cache: 1]; // // node Inquire[3]: x = 258, y = 461, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "is not empty" // GetEvents_Inquire_3_out_1 = Inquire( GetEvents_Include_2_out_1, "is not empty", NULL ) [instance: 3, cache: 1]; // // node Transmitter[9]: x = 549, y = 146, inputs = 1, label = was_no_event // was_no_event = GetEvents_Inquire_2_out_1; // // node Receiver[11]: x = 55, y = 446, inputs = 1, label = was_no_event // GetEvents_Receiver_11_out_1[cache: 0] = was_no_event; // // node Switch[10]: x = 406, y = 585, inputs = 3, label = Switch // input[3]: defaulting = 0, visible = 1, type = 67108863, value = 0 // GetEvents_Switch_10_out_1 = Switch( GetEvents_Receiver_11_out_1, GetEvents_Compute_10_out_1, 0 ) [instance: 10, cache: 1]; // // node Output[1]: x = 389, y = 672, inputs = 1, label = Output // parameter: position = 1, name = 'position', value = ' ', descriptive = 0, description = ' x,y position of event', required = 0, visible = 1 // position = GetEvents_Switch_10_out_1; // // node Switch[9]: x = 314, y = 586, inputs = 3, label = Switch // input[3]: defaulting = 0, visible = 1, type = 67108863, value = 0 // GetEvents_Switch_9_out_1 = Switch( GetEvents_Receiver_11_out_1, GetEvents_Inquire_3_out_1, 0 ) [instance: 9, cache: 1]; // // node Output[2]: x = 314, y = 668, inputs = 1, label = Output // parameter: position = 2, name = 'event_occurred', value = '(NULL)', descriptive = 1, description = ' whether or not a requested event occurred', required = 0, visible = 1 // event_occurred = GetEvents_Switch_9_out_1; // // decorator Annotate pos=(449,57) size=204x44 style(Label), value = // annotation user_begin: 51 // annotation user: Determine whether or not // annotation user: any mouse event occurred. // annotation user_end: // // decorator Annotate pos=(481,234) size=230x44 style(Label), value = // annotation user_begin: 39 // annotation user: extract the x,y position from the // annotation user: event // annotation user_end: // // decorator Annotate pos=(5,140) size=300x76 style(Label), value = // annotation user_begin: 139 // annotation user: These computes determine whether the // annotation user: mouse button pressed and the event type // annotation user: (button up, down, or motion) match the // annotation user: requested event // annotation user_end: // // decorator Annotate pos=(433,318) size=369x60 style(Label), value = // annotation user_begin: 119 // annotation user: create a field with the x,y of the event as "positions" // annotation user: and whether or not it was the requested type of // annotation user: event as "data" // annotation user_end: // // decorator Annotate pos=(567,402) size=348x44 style(Label), value = // annotation user_begin: 72 // annotation user: Use Include to save only events which match the // annotation user: criteria set by the user // annotation user_end: // // decorator Annotate pos=(341,473) size=298x60 style(Label), value = // annotation user_begin: 114 // annotation user: Use Inquire to figure out if there were any // annotation user: events of the requested type (is the // annotation user: field after Include empty or not) // annotation user_end: // // decorator Annotate pos=(720,506) size=285x28 style(Label), value = // annotation user_begin: 42 // annotation user: Extract just the x,y position of the event // annotation user_end: // // decorator Annotate pos=(486,641) size=216x44 style(Label), value = // annotation user_begin: 63 // annotation user: If an event of the requested // annotation user: type occurred, output the x,y. // annotation user_end: // // decorator Annotate pos=(14,630) size=280x60 style(Label), value = // annotation user_begin: 103 // annotation user: output whether or not an event of the // annotation user: requested type occurred. If no event at // annotation user: all occurred, output 0. // annotation user_end: // network: end of macro body } GetEvents_Input_3_out_1 = NULL; GetEvents_Compute_6_out_1 = NULL; GetEvents_Input_1_out_1 = NULL; GetEvents_Compute_7_out_1 = NULL; GetEvents_Input_2_out_1 = NULL; GetEvents_Compute_8_out_1 = NULL; GetEvents_Compute_9_out_1 = NULL; GetEvents_Construct_3_out_1 = NULL; GetEvents_Include_2_out_1 = NULL; GetEvents_Extract_2_out_1 = NULL; GetEvents_Compute_10_out_1 = NULL; GetEvents_Inquire_2_out_1 = NULL; GetEvents_Inquire_3_out_1 = NULL; GetEvents_Transmitter_9_out_1 = NULL; GetEvents_Receiver_11_out_1 = NULL; GetEvents_Switch_10_out_1 = NULL; GetEvents_Switch_9_out_1 = NULL;