How to Change a button state when textFields become not empty

Patrick CARDONA <[email protected]> Thu, 26 Feb 2026 13:12:28 +0100
Newsgroups gmane.comp.lib.gnustep.general
Message-ID <5808a2d28cc27c2c4b9f59dca49b898c@pi500>
Hello,

I am working on an Internet Shortcuts Manager (aka SaveLink).

I associated the same action (statechange:) on my two fields ('name' 
and 'link').
If they are not empty, the 'savebutton' should be enabled.
But my button state does never change. Initial state is disabled and 
it remains in this state.

In the Header:
> @interface SaveLink : NSObject
> {
>   IBOutlet id name;
>   IBOutlet id link;
>   IBOutlet id savebutton;
> }
> 
> - (IBAction) statechange: (id)sender;
> - (IBAction) save: (id)sender;
> - (IBAction) reset: (id)sender;
> - (IBAction) open:  (id)sender;
> 
> @end
> 

In the class:

> @implementation
>  // (...)
> 
> - (IBAction) statechange: (id)sender
> {
>   // We retrieve values from textFileds outlets
>   NSString *nameLink = [name stringValue];
>   NSString *urlLink = [link stringValue];
>   int lenName = [nameLink length];
>   int lenLink = [urlLink length];
>   if(lenName>0 && lenLink>0)
>   {
>     [savebutton setEnabled:YES];
>   }
>   else
>   { 
>     [savebutton setEnabled:NO];
>   }
> }
> 
> @end
> 

Any idea to make it work?

I joined the complete project. All was working as expected before I 
added this test stage. But I think it is needed as we should not want 
empty fields to perform the  save action.

<SaveLink.tar.gz>

Regards,
Patrick

-- 
Patrick Cardona - Pi500 - GNU/Linux aarch64 (Debian 13.3)
Xorg (1:7.7+24) - libcairo2 (1.18.4-1+rpt1 arm64) - Window Maker 
(0.96.0-4)
GWorkspace (1.1.0 - 02 2025) - Theme: AGNOSTEP - Classic - MUA: 
GNUMail (1.4.0 - rev.947)
SaveLink.tar.gz (application/x-gzip, 13.5 KB) - not displayed