简体   繁体   English

让GtkButton看起来很沮丧

[英]Make a GtkButton look depressed

So I have a shape drawing program, with a toolbar with buttons for box, circle, segment, etc. If you click a shape button (such as the box button), you can drag the mouse to draw that kind of shape. 所以我有一个形状绘图程序,带有一个带有按钮的工具栏,圆形,线段等。如果单击一个形状按钮(例如框按钮),则可以拖动鼠标来绘制那种形状。 I didn't use toggle buttons because I don't want it so that if you draw a box you have to "untoggle" the box button before you can "toggle" the circle button, for example. 我没有使用切换按钮,因为我不想要它,所以如果你画一个盒子,你必须“解开”盒子按钮才能“切换”圆形按钮,例如。 However, I'm trying to make it so that when you have clicked a shape button, it looks "depressed" so you know what shape you're drawing until you click another button. 但是,我正在尝试这样做,以便当你点击一个形状按钮时,它看起来“郁闷”,所以你知道你要绘制的形状,直到你点击另一个按钮。

I try to make it look depressed by putting this in the clicked callback: 我试着把它放在点击的回调中让它看起来很郁闷:

gtk_widget_set_state_flags(button, GTK_STATE_FLAG_ACTIVE, TRUE);

However, it's not working. 但是,它不起作用。 Any help is greatly appreciated! 任何帮助是极大的赞赏!

I think it's easier to use a toggle button, but programmatically untoggle them when the user is done drawing the box. 我认为使用切换按钮更容易,但是当用户完成绘制框时,以编程方式取消它们。 This way you don't have to fight the API or hurt any buttons' feelings. 这样你就不必打击API或伤害任何按钮的感觉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM