Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions public/usage-examples/windows/window_has_focus-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
33 changes: 33 additions & 0 deletions public/usage-examples/windows/window_has_focus-1-example.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions public/usage-examples/windows/window_has_focus-1-example.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show Whether the Window Has Focus