diff --git a/public/usage-examples/windows/window_has_focus-1-example-oop.cs b/public/usage-examples/windows/window_has_focus-1-example-oop.cs new file mode 100644 index 000000000..720197d88 --- /dev/null +++ b/public/usage-examples/windows/window_has_focus-1-example-oop.cs @@ -0,0 +1,38 @@ +using SplashKitSDK; + +namespace WindowHasFocusExample +{ + public class Program + { + public static void Main() + { + SplashKit.OpenWindow("Window Has Focus", 800, 600); + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + // Check whether the current window has focus + bool hasFocus = SplashKit.WindowHasFocus(SplashKit.CurrentWindow()); + + SplashKit.ClearScreen(Color.White); + + // Show the current focus state on screen + SplashKit.DrawText("Click on or away from the window to change focus.", Color.Black, 120, 220); + + if (hasFocus) + { + SplashKit.DrawText("Window has focus", Color.Green, 280, 280); + } + else + { + SplashKit.DrawText("Window does not have focus", Color.Red, 240, 280); + } + + SplashKit.RefreshScreen(60); + } + + SplashKit.CloseAllWindows(); + } + } +} \ No newline at end of file diff --git a/public/usage-examples/windows/window_has_focus-1-example-top-level.cs b/public/usage-examples/windows/window_has_focus-1-example-top-level.cs new file mode 100644 index 000000000..4f77a73d4 --- /dev/null +++ b/public/usage-examples/windows/window_has_focus-1-example-top-level.cs @@ -0,0 +1,30 @@ +using SplashKitSDK; +using static SplashKitSDK.SplashKit; + +OpenWindow("Window Has Focus", 800, 600); + +while (!QuitRequested()) +{ + ProcessEvents(); + + // Check whether the current window has focus + bool hasFocus = WindowHasFocus(CurrentWindow()); + + ClearScreen(ColorWhite()); + + // Show the current focus state on screen + DrawText("Click on or away from the window to change focus.", ColorBlack(), 120, 220); + + if (hasFocus) + { + DrawText("Window has focus", ColorGreen(), 280, 280); + } + else + { + DrawText("Window does not have focus", ColorRed(), 240, 280); + } + + RefreshScreen(60); +} + +CloseAllWindows(); \ No newline at end of file diff --git a/public/usage-examples/windows/window_has_focus-1-example.cpp b/public/usage-examples/windows/window_has_focus-1-example.cpp new file mode 100644 index 000000000..55f686fd1 --- /dev/null +++ b/public/usage-examples/windows/window_has_focus-1-example.cpp @@ -0,0 +1,33 @@ +#include "splashkit.h" + +int main() +{ + open_window("Window Has Focus", 800, 600); + + while (!quit_requested()) + { + process_events(); + + // Check whether the current window has focus + bool has_focus = window_has_focus(current_window()); + + clear_screen(COLOR_WHITE); + + // Show the current focus state on screen + draw_text("Click on or away from the window to change focus.", COLOR_BLACK, 120, 220); + + if (has_focus) + { + draw_text("Window has focus", COLOR_GREEN, 280, 280); + } + else + { + draw_text("Window does not have focus", COLOR_RED, 240, 280); + } + + refresh_screen(60); + } + + close_all_windows(); + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/windows/window_has_focus-1-example.gif b/public/usage-examples/windows/window_has_focus-1-example.gif new file mode 100644 index 000000000..79f4827ff Binary files /dev/null and b/public/usage-examples/windows/window_has_focus-1-example.gif differ diff --git a/public/usage-examples/windows/window_has_focus-1-example.py b/public/usage-examples/windows/window_has_focus-1-example.py new file mode 100644 index 000000000..1ca64c756 --- /dev/null +++ b/public/usage-examples/windows/window_has_focus-1-example.py @@ -0,0 +1,23 @@ +from splashkit import * + +open_window("Window Has Focus", 800, 600) + +while not quit_requested(): + process_events() + + # Check whether the current window has focus + has_focus = window_has_focus(current_window()) + + clear_screen(color_white()) + + # Show the current focus state on screen + draw_text_no_font_no_size("Click on or away from the window to change focus.", color_black(), 120, 220) + + if has_focus: + draw_text_no_font_no_size("Window has focus", color_green(), 280, 280) + else: + draw_text_no_font_no_size("Window does not have focus", color_red(), 240, 280) + + refresh_screen_with_target_fps(60) + +close_all_windows() \ No newline at end of file diff --git a/public/usage-examples/windows/window_has_focus-1-example.txt b/public/usage-examples/windows/window_has_focus-1-example.txt new file mode 100644 index 000000000..620bd43a5 --- /dev/null +++ b/public/usage-examples/windows/window_has_focus-1-example.txt @@ -0,0 +1 @@ +Show Whether the Window Has Focus \ No newline at end of file