[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Renaissance - LPT_Interface.app - implementing button action
From: |
Nicola Pero |
Subject: |
Re: Renaissance - LPT_Interface.app - implementing button action |
Date: |
Sat, 21 Aug 2010 10:41:44 +0100 |
Because the button is toggle type I must to write the code so so when
the button has title="1" then the action code must to write logical
1 to
the Data Port bit, but when the button title="0" then it must to write
logical 0 to the bit.
This all is not specific to Renaissance ... it has to do with GNUstep/
OpenStep/Cocoa programming ;-)
Your button has an action, and a target. For example,
<button action="togglePort:" target="#NSOwner" />
this means that when the button is clicked, the 'togglePort:' method
of your #NSOwner object will be invoked.
So, all you need to do is implement it:
/* (inside the @implementation of the class from which you instantiate
the #NSOwner) */
/* Pseudo-code, I haven't tested any of this. */
- (void) togglePort: (id)sender
{
NSString *title = [sender title];
if ([title isEqualToString: @"1"])
{
// "write logical 1 to the data port"
}
else if ([title isEqualToString: @"0"])
{
// "write logical 0 to the data port"
}
}
For more information / worked-out examples, check Renaissance/Examples/
Applications/. Just find an application with
some buttons in it, and check how the action/target is implemented/
works. :-)
Is it good to write this code in main.m file?
Also, how can I achieve that that the Error messages appeares in the
label text which id="StatLine"?
You'll need to catch the error message first.
When you want to display the error message, you need to have a way to
reference your <label> object from your
code. To do this, you need to have established a "connection". So ...
* first of all, make sure your <label> has a unique id that
identifies it - so that you can reference it:
<label id="errorMessageLabel">
* then, you need an instance variable in your NSOwner object where
you can store a reference to the <label>. To the list
of instance variables of your NSOwner, add
NSTextField *errorMessageLabel;
* then, add a <connector> section at the end of your gsmarkup file
which will automatically set the 'errorMessageLabel' instance
variable to point to the <label> object with the same id. Here it is --
<connectors>
<outlet source="#NSOwner" target="#errorMessageLabel"
key="errorMessageLabel" />
<connectors>
For a full example, you can check Renassaince/Examples/Applications/
Finger -- FingerWindowBig.gsmarkup has this #text
element where things get written into. :-)
Thanks