Skip to content

Commit 266faac

Browse files
committed
Added --print command line option that enables ouptut of the event
messages to the console.
1 parent 196aecc commit 266faac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/ui/vsginput/vsginput.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ class InputHandler : public vsg::Inherit<vsg::Visitor, InputHandler>
99
vsg::ref_ptr<vsg::Text> scroll_text;
1010
vsg::ref_ptr<vsg::Text> window_text;
1111
vsg::ref_ptr<vsg::Text> frame_text;
12+
bool printToConsole = false;
1213

1314
InputHandler(vsg::ref_ptr<vsg::Text> in_keyboard_text, vsg::ref_ptr<vsg::Text> in_pointer_text,
14-
vsg::ref_ptr<vsg::Text> in_scroll_text, vsg::ref_ptr<vsg::Text> in_window_text, vsg::ref_ptr<vsg::Text> in_frame_text) :
15+
vsg::ref_ptr<vsg::Text> in_scroll_text, vsg::ref_ptr<vsg::Text> in_window_text, vsg::ref_ptr<vsg::Text> in_frame_text,
16+
bool in_printToConsole) :
1517
keyboard_text(in_keyboard_text),
1618
pointer_text(in_pointer_text),
1719
scroll_text(in_scroll_text),
1820
window_text(in_window_text),
19-
frame_text(in_frame_text)
21+
frame_text(in_frame_text),
22+
printToConsole(in_printToConsole)
2023
{
2124
}
2225

2326
void assign(vsg::Text& text, const std::string& str)
2427
{
28+
if (printToConsole) vsg::info(str);
29+
2530
auto text_string = text.text.cast<vsg::stringValue>();
2631

2732
if (text_string)
@@ -144,6 +149,7 @@ int main(int argc, char** argv)
144149
auto event_read_filename = arguments.value(std::string(""), "-i");
145150
auto event_output_filename = arguments.value(std::string(""), "-o");
146151
auto font_filename = arguments.value(std::string("fonts/times.vsgb"), "--font");
152+
bool printToConsole = arguments.read("--print");
147153

148154
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
149155

@@ -344,7 +350,7 @@ int main(int argc, char** argv)
344350
viewer->addEventHandler(vsg::CloseHandler::create(viewer));
345351

346352
// assign Input handler
347-
viewer->addEventHandler(InputHandler::create(keyboard_text, pointer_text, scroll_text, window_text, frame_text));
353+
viewer->addEventHandler(InputHandler::create(keyboard_text, pointer_text, scroll_text, window_text, frame_text, printToConsole));
348354

349355
// main frame loop
350356
while (viewer->advanceToNextFrame())

0 commit comments

Comments
 (0)