我正在使用 gtk+ 2.0 用 C 语言开发一个项目。
我必须检查用户是否按下了左键单击图像。我想在按下左键时调用一个函数并获取鼠标的位置,但是我该怎么做呢?
我有这个代码序列:
printf("%p\n", gameGUI);
printf("label %p\n", gameGUI->labelRoundType);
gui_setRoundType(gameGUI->labelRoundType,
gameGUI->game->rounds[roundId]);
printf("label %p\n", gameGUI->labelRoundType);
printf("%p\n", gameGUI);
Run Code Online (Sandbox Code Playgroud)
函数gui_setRoundType的代码.
int gui_setRoundType(GtkWidget *roundTypeLabel, struct Round *round)
{
if (round == NULL)
return ROUND_NULL;
if (roundTypeLabel == NULL)
return POINTER_NULL;
char type[1] = { '\0' };
intToChar(round->roundType, type);
gtk_label_set_text(GTK_LABEL(roundTypeLabel), type);
return NO_ERROR;
}
Run Code Online (Sandbox Code Playgroud)
GameGUI结构的代码:
struct GameGUI {
struct Game *game;
struct Select *select;
struct PlayerCards *playerCards;
struct PlayersGUI *playersGUI;
struct CardsFromTable *cardsFromTable;
struct BidGUI *bidGUI;
GtkWidget *windowTable;
GtkWidget *fixedTable;
GtkWidget *buttonShowScore;
GtkWidget *imageTrump;
GtkWidget *labelRoundType;
GtkWidget *labelNoOfBids; …
Run Code Online (Sandbox Code Playgroud)