Página 1 de 1

Gtk_Button_New

Enviado: 09 Jul 2008 12:07
por jamazevedo

Código: Selecionar todos

   Local oWindow , oButtonIncluir
   gtk_init()
   oWindow := gtk_window_new( GTK_WINDOW_TOPLEVEL )
   gtk_widget_set_usize( oWindow, 640, 480 )
   gtk_window_set_title( oWindow, "Cadastros" )
   gtk_window_set_position( oWindow, GTK_WIN_POS_CENTER )
   ....
   oButtonIncluir := gtk_button_new_with_mnemonic( "_Incluir" )
   ...
   gtk_container_add( oWindow, oButtonIncluir )
   gtk_widget_show( oButtonIncluir )
   ...
   gtk_signal_connect( oWindow         , "destroy", {|| gtk_main_quit() } )
   ...
   gtk_signal_connect( oButtonIncluir  , "clicked", {|| incluir( oWindow ) } )
   ...
   gtk_widget_show( oWindow )
Como faço para "desabilitar/habilitar" o botão "oButtonIncluir" dentro da rotina incluir() ?

Os fontes que acompanham a Classe TButton não mostra como isso ocorre, no exemplo da TButton aparece:

Código: Selecionar todos

...
oButtonIncluir:Enable()
...
oButtonIncluir:Disable()
...
Não consegui localizar esse código.

Re: Gtk_Button_New

Enviado: 09 Jul 2008 19:17
por marcosgambeta
jamazevedo escreveu:Como faço para "desabilitar/habilitar" o botão "oButtonIncluir" dentro da rotina incluir() ?
Para habilitar/desabilitar widgets, temos a função abaixo:

gtk_widget_set_sensitive (pButton, .T.) // habilita
gtk_widget_set_sensitive (pButton, .F.) // desabilita

Código: Selecionar todos

gtk_widget_set_sensitive ()
void gtk_widget_set_sensitive (GtkWidget *widget, gboolean sensitive);
Sets the sensitivity of a widget. A widget is sensitive if the user can interact with it. Insensitive widgets are "grayed out" and the user can't interact with them. Insensitive widgets are known as "inactive", "disabled", or "ghosted" in some other toolkits.
widget : a GtkWidget  
sensitive : TRUE to make the widget sensitive
jamazevedo escreveu:Os fontes que acompanham a Classe TButton não mostra como isso ocorre, ... Não consegui localizar esse código.
A classe TButton é descendente da classe TControl.

CLASS TButton INHERIT TControl

Os métodos Enable e Disable estão definidos nela e a classe TButton herda os métodos.

METHOD Enable() INLINE gtk_widget_set_sensitive(::handle, TRUE)
METHOD Disable() INLINE gtk_widget_set_sensitive(::handle, FALSE)

Re: Gtk_Button_New

Enviado: 10 Jul 2008 10:59
por jamazevedo
Agora entendi. Valeu!