From 456be7a8197bd63b6dea0752878a24333ca917f4 Mon Sep 17 00:00:00 2001 From: RobinsAviary Date: Thu, 2 Oct 2025 15:18:53 -0400 Subject: [PATCH] added image check --- examples/core/core_clipboard_text.c | 35 +++++++++++++++++++------- examples/core/core_clipboard_text.png | Bin 15863 -> 15878 bytes 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/examples/core/core_clipboard_text.c b/examples/core/core_clipboard_text.c index 302e21918..9e9f3a3d1 100644 --- a/examples/core/core_clipboard_text.c +++ b/examples/core/core_clipboard_text.c @@ -1,10 +1,10 @@ -/******************************************************************************************* +/******************************************************************************************* * * raylib [core] example - clipboard text * * Example complexity rating: [★☆☆☆] 1/4 * -* Example originally created with raylib 5.5 +* Example originally created with raylib 5.6-dev * * Example contributed by Robin (@RobinsAviary) and reviewed by Ramon Santamaria (@raysan5) * @@ -73,16 +73,32 @@ int main(void) // React to the user pressing paste if (pastePressed) { - // Get the text from the user's clipboard. Most operating systems explicitly hide this information until the key combination is pressed while the window is selected - clipboardText = GetClipboardText(); + // Most operating systems hide this information until the user presses Ctrl-V on the window. - // Reset values + // Check to see if the clipboard contains an image + Image image = GetClipboardImage(); + + if (IsImageValid(image)) + { + // Unload the image + UnloadImage(image); + // Update visuals + popupText = "clipboard contains image"; + } + else + { + // Get text from the user's clipboard + clipboardText = GetClipboardText(); + + // Update visuals + popupText = "text pasted"; + pasteAnim = animMaxTime; + } + + // Reset animation values textTimer = maxTime; textAnim = animMaxTime; - pasteAnim = animMaxTime; textAlpha = 1; - // Update the text that pops up at the bottom of the screen - popupText = "text pasted"; } // React to the user pressing copy @@ -110,7 +126,8 @@ int main(void) textIndex += 1; - if (textIndex >= sizeof(copyableText) / sizeof(const char*)) { // Length of array + if (textIndex >= sizeof(copyableText) / sizeof(const char*)) // Length of array + { // Loop back to the other end textIndex = 0; } diff --git a/examples/core/core_clipboard_text.png b/examples/core/core_clipboard_text.png index 437d8ea1615371b5a70271a8973797487691d22f..caa9b314a694bdb9316f9f8d07161887d53887e6 100644 GIT binary patch delta 457 zcmexf-BvR}h4Ji0RTC?&!wx^QceFjvNHm>%kY9w;!a1RY^IFC!naKw^MR^)83M`1` z=qYn>6TUsUkxP;_gFVHBck)6;af=KNp8Wy|idVf~{C3!9Hpj)V=|-)RL9M~p7tapx z998u{A=~oDb)7Zm%_=bPy~&PT;+#B+2D@0YO=SBf8`?-4d(2}z zXd2x3F3HJQ%HZpcG$)R;Jp!-!oD@A*Sr^W1&vt7KDG#!)xp-Le?%(EzDVs0;u>-l4 zqsS?tge}En>tq8P8JUQTRNgTe~DWM4f DJmR-3 delta 503 zcmZpx`CdIig>m0TRTC>N=CyxKV-DwT36Pq6kW+*+O3`2!OSZ|;zR8V@5&{==St8sH zR~57zxZXB-aiHO3K~r%KI~KQe2RGrLlN-4t^ce0sH9V0N_)@FzLiziVcfyS?n^zt; zWp41EH^G{tRbl5ll@z^Q`#nPaSN^-W$9VEVelgBwORxc#pCcQP^j%9}*2RXO0@r;w z7S0sRdOK6$s!Y<~)_3+_Bveb;+9Lig*_Cgye)2~iF-`_s=Y$fr6qCJ^Kk`V5U(jXA zDB}`aS>Er z9o)R6ep*%8pU5bjypdg$v&RW+q-8(I-v$?SSv2;svpfs>GO^03TAbtUPX(3!(=|ou zaRsdwEB`r}w_mcAInt(l=H5kH<;6>nPgZ0U;Y{FbyeK*0;up)w2l=H16aM`A`uhLH z56kK}dfp{U`i4$cWEJO-WLj*juy|$Cq}$evKbeVRj=aJxTd?*ev gv