added image check
This commit is contained in:
parent
b5b54c20f5
commit
456be7a819
|
|
@ -1,10 +1,10 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - clipboard text
|
* raylib [core] example - clipboard text
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★☆☆☆] 1/4
|
* 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)
|
* Example contributed by Robin (@RobinsAviary) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
|
|
@ -73,16 +73,32 @@ int main(void)
|
||||||
// React to the user pressing paste
|
// React to the user pressing paste
|
||||||
if (pastePressed)
|
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
|
// Most operating systems hide this information until the user presses Ctrl-V on the window.
|
||||||
clipboardText = GetClipboardText();
|
|
||||||
|
|
||||||
// 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;
|
textTimer = maxTime;
|
||||||
textAnim = animMaxTime;
|
textAnim = animMaxTime;
|
||||||
pasteAnim = animMaxTime;
|
|
||||||
textAlpha = 1;
|
textAlpha = 1;
|
||||||
// Update the text that pops up at the bottom of the screen
|
|
||||||
popupText = "text pasted";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// React to the user pressing copy
|
// React to the user pressing copy
|
||||||
|
|
@ -110,7 +126,8 @@ int main(void)
|
||||||
|
|
||||||
textIndex += 1;
|
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
|
// Loop back to the other end
|
||||||
textIndex = 0;
|
textIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user