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 zcmV;)0XF{kdxm_FBmvE_B{Vt;!$A3KxQ6FwVKtM%4-^SFLtu0X)@aHclfelU41v)Q zpj!xxc0fiG+mnF`83kwuWHb$vp#c{-Xb23y5MUwIOX&MRzBZghF@o5AA~1b0_2}ln z48N}YlR*j>2@D}Hx&&)99gdSRJR37eo&mu% zQ-SVcLNgjL^|)q22+fQT>kdL8Nvb<>nTKmeg;aM^JABc@8QuMZ;bgPX{63Sx4-^P; zLSS?TWHhytFgzR_SZHMvsUz#e?g<&Fv_bAn0U>?l&g6{FT#S|ylkox+2}3aiMrS}q z)9sUi3K$>&-9mt7Ga#gn?4$4bAhZW$pwbAf_lywhFKX?98O>{xu?!ao&kz`$0U1qi zlaVzUDs&40ithn|xs=rVDhTcQAS6$%Q>RGXOF^u9YVR2#H+*67GrDJFv{V_B!3h)y z3?VQ&12UQplQAwL2@=D5um0TRTC>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$fr6qCI`o}@U?jTvQJ zVk^tr9?asDe3_YOaA&X4EcwZXdSaXnK<`*F8_k+FInY!_++;SRVrf3>uX+4V)edf6 zQa`P#>`!DAPTt5a%Gu)tHqx>m6)VSxPn%T zmH(W~+b`M59BETNbMK<9^5Uh(Co3|Fa3=6IUX+}0@rxzUm(qd>e|~*^{r}>JWpx}q z?-C__LnkY;igQRZEjCtIyfSI>MH8{f1}v