this is an example of highlighting text and see if cntrl c is pressed after. I dont use clipboard but this demo is from the previous code I had.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 2D project that uses Dark GDK
// it can be used as a starting point in making your own 2D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
void TextSetup();
void fixUV( char c );
int iNextTextSprite;
int sizetext;
double size;
void Texts ( int iX , int iY , int iSize , char* czText , bool bHorizonalCenter = false , bool bVerticalCenter = false,int sprite=1);
void TextSetup()
{
dbLoadImage ( "fontdefault.png" , 100 );
}
void Texts ( int iX , int iY , int iSize , char* czText , bool bHorizontalCenter , bool bVerticalCenter, int sprite)
{
size=iSize;
// if bHorizonalCenter is true then work out the x coordinate to make the text centered
if ( bHorizontalCenter )
{
iX = (int)(( dbScreenWidth() / 2 ) - ( ( strlen( czText ) * iSize ) / 2 ));
}
// if bHorizonalCenter is true then work out the y coordinate to make the text centered
if ( bVerticalCenter )
{
iY = ( dbScreenHeight() / 2 ) - ( iSize / 2 );
}
sizetext=(int)strlen( czText );
// loop through and draw each character
for ( int i = 0 ; i < sizetext ; i++ )
{
// if ( czText[i] == 32 )
// iX += iSize;
// else
// {
dbSprite ( iNextTextSprite , iX , iY , sprite );
fixUV( czText[i]);
dbSizeSprite ( iNextTextSprite , iSize , iSize );
iX += iSize;
iNextTextSprite++;
// }
}
}
void fixUV( char c )
{
c=c-32;
// so we offset it to line up with our image
float U = 0.0f;
float V = 0.0f;
int iY = c / 10;
int iX = c % 10;
float fOffset = 1.0f / 10.0f;
U = iX * fOffset;
V = iY * fOffset;
dbSetSpriteTextureCoord ( iNextTextSprite , 0 , U , V );
dbSetSpriteTextureCoord ( iNextTextSprite , 1 , U + fOffset , V );
dbSetSpriteTextureCoord ( iNextTextSprite , 2 , U , V + fOffset );
dbSetSpriteTextureCoord ( iNextTextSprite , 3 , U + fOffset , V + fOffset );
}
void hidesprite()
{
for(int i=100+sizetext+1; i<=iNextTextSprite; i++)
{
dbHideSprite(i);
}
}
void setdef(int r, int g, int b)
{
int i;
for ( i = 100 ; i <= 100+sizetext ; i++ )
{
dbSetSpriteDiffuse( i, r, g, b );
}
hidesprite();
}
bool intxc(int xcnt,int mousex,int mousey)
{
bool selected=false;
if(mousex>=dbSpriteX(xcnt)&&mousey>=dbSpriteY(xcnt)&&mousex<=dbSpriteX(xcnt)+size&&mousey<=dbSpriteY(xcnt)+size)//mousex>=dbSpriteX(xcont)&&mousey>=dbSpriteY(xcont)&&mousex<=dbSpriteX(xcont)+dbSpriteWidth(xcont))//&&mousex<=dbSpriteX(xcont)+dbSpriteWidth(xcont)&&mousey<=dbSpriteY(xcont)+dbSpriteHeight(xcont))
{
// xx=xcontt;
// dbPrint(xx);
dbText(100,100,"true");
dbShowSprite(xcnt+sizetext);
//dbShowSprite(101+sizetext+1);
selected=true;
}
return selected;
}
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
iNextTextSprite=100;
dbSyncRate ( 60 );
int xcontt;
double xx;
iNextTextSprite=101;
dbLoadImage ( "fontdefault2.bmp" , 100);
// dbSetSpriteImage(101,100);
// dbSetSpriteDiffuse( 101, 255, 255, 255 );
Texts (0,0,15,"Hi there",false,false,100);
//dbSprite (1,0,0,1);
dbSetImageColorKey ( 255, 255, 255 );
dbLoadImage ( "fontdefaulthighlight.bmp" , 2 );
Texts (0,0,15,"Hi there",false,false,2);
//dbSprite (2,0,0,2);
bool mccount=false;
//dbSetSpriteDiffuse( 1, 100, 100, 100 );
//Texts(10 , 10,14,"h",false,false);
setdef(0,0,0);
double mousex,mousey, width,heigth;
// Texts( 0 , 0 , 17 , "hhi there\nbyther\ngo there" , false , false );
// setdef();
while ( LoopGDK ( ) )
{
if ( dbEscapeKey ( ) )
break;
// mouseX = dbMouseX();
//mouseY = dbMouseY();
if(dbMouseClick()==1)
{
mousex = dbMouseX();
mousey = dbMouseY();
//dbText(100,100,"true");
//dbPrint(mousex);
int xtemp=100;
for(xcontt=101;xcontt<= 100+sizetext;xcontt++)
{
mccount=intxc(xcontt,mousex,mousey);
// width=size;
// heigth=size;
//dbPrint(size);
// xtemp++;
}
}
if(dbMouseClick()!=1&&dbKeyState(29)&&dbKeyState(46))
{
hidesprite();
}
dbSync ( );
}
for ( int i = 100 ; i < iNextTextSprite ; i++ )
{
if ( dbSpriteExist ( i ) )
dbDeleteSprite ( i );
}
iNextTextSprite = 100;
return;
}
Go through yourself at a wall.