Choosing a button from a view - basic4android

I'm stuck with some syntax on figuring out which of 2 buttons in a view was clicked. I have multiple views - so what happens first is text is assigned to the 2 buttons based on the current view - then what I want to have happen is an action based on which button was clicked. My views work ok - it's the button code that I'm trying to figure out. I'm also trying to avoid writing a sub for each individual button click - and want generic code that I can reuse for any of the views that will always have 2 buttons.
Sub catchtheClick
Dim button1,button2,clickButton As Button
clickButton = Sender
If (we figure out which view - view1 for example) Then
button1.Text = "view1-button1"
button2.Text = "view1.button2"
button1.Tag = "btn1"
button2.Tag = "btn2"
Select clickButton.Tag
Case "btn1"
(we go to another view etc.)
Case "btn2" Then
(we go to some other view etc.)
End Select
End If
End Sub

Did you see the Arrays of views tutorial?
Your code is wrong. You are declaring button1 and button2 which are never initialized or assigned.
The simplest solution is to use the Tag property to mark each button and then check clickButton.Tag and find which button was pressed.

Avoid the confusion - simply use the Designer to add the views and then use "Tools .... Generate Members" to add all your Dim statements and Event statments.

I made a few changes - including the location of the button init and event names - all works fine now.

Related

Access to Checkboxes (NSButton) in a Controller View

I have a View with 50 checkboxes (NSButton) in a OS X app. I need to access to each one in code, but the only way I find is to create 50 IBOutlet bindings. The IBOutlet collection is not available in OS X. How can I do?
One way to refer to the 50 checkboxes in your ViewController class (I'm assuming that you use view controllers) is by first retrieving the superview that contains each of the 50 checkboxes. This will be an NSView object. To distinguish between the checkboxes I recommend setting different tag values right in interface builder, but it really depends on what you want to do with the checkboxes. Then, you can use a loop to iterate through each of the subviews in this view, like this:
for i in view.subviews.filter({$0 as? NSButton != nil}).map({$0 as! NSButton}) {
if i.bezelStyle == .regularSquare && !(i.cell as! NSButtonCell).imageDimsWhenDisabled {
print(i.title)
}
}
The if condition basically utilizes two properties of checkboxes to distinguish them from any other type of NSButton.
In this example, I simply printed the title of each checkbox. You can use a switch statement if you want to perform different tasks depending on which checkbox it is. The good thing is that with this method you can have infinitely many checkboxes. The iteration order is left to right, top to bottom.

Edit Name of cell upon tap - Swift

I want to edit the text in a cell by tapping and I was wondering if there is a way to do it other than by adding a text field. is there something in the table view delegate that I missed?
You can create cell (or any other UIResponder subclass) that conforms UITextInput protocol (or maybe UIKeyInput is enough). Here is simple example (old link)
Notice,
you should set cell.canBecomeFirstResponder = true.
To show keyboard use cell.becomeFirstResponder()
Maybe there something else, that you should do. I recommend reading docs.
...Or use UITextField :)
We use an array to display no of text label in cell.
so you can do is, you can use a text field and a button on a view.
In button action add a line of code like stringArray[2] = "new string" to replace the particular element from array and when you enter a text and press a button the element will get replaced and just reload the table view.
And you can also write the method in didSelectRowAtIndexPath, write stringArray[indexPath.row] = "new string" and reload the table view and it is done.

How to add a user control to populate records on a master-detail form?

Please help, Oracle form expert!
I created a master-detail form, and the user now wants to add a control to populate records on it--open items, closed items or all items.
I created a new Data Block that has one Item (Radio_Group), and laid out 3 Radio Buttons OPEN, CLOSED & ALL that should match a table column with values like 'Sent1, Sent2, Sent3, Reviewed' for OPEN, 'Rejected, Declined' for CLOSED and ALL should cover both of them.
On Radio_Group Property_Pallete, Item Type: Radio Group; Subclass Info:RADIO_GROUP; Mapping of Other Values: Open; & Initial Value: Open
For 3 Radio Buttons, Label & Radio Button Value are the same: Open, closed & ALL.
On the WHEN-RADIO-CHANGED, I wrote:
IF :RADIO_DISPLAY.DISPLAY = 'OPEN' THEN
SET_BLOCK_PROPERTY('CCR_MANAG_MAIN', DEFAULT_WHERE,
'upper(ISG_STATUS) like ''SEN%'' or upper(ISG_STATUS) like ''%REVIEW''');
GO_BLOCK('CCR_MANAG_MAIN');
CLEAR_FORM('NO_VALIDATE');
execute_query;
IFELS upper(:RADIO_DISPLAY.DISPLAY) = upper('CLOSED') THEN
SET_BLOCK_PROPERTY('CCR_MANAG_MAIN', DEFAULT_WHERE
,'upper(ISG_STATUS) not like ''SEN%'' and upper(ISG_STATUS) not like ''%REVIEW''');
GO_BLOCK('CCR_MANAG_MAIN');
CLEAR_FORM('NO_VALIDATE');
execute_query;
ELSE
SET_BLOCK_PROPERTY('CCR_MANAG_MAIN', DEFAULT_WHERE,'');
GO_BLOCK('CCR_MANAG_MAIN');
CLEAR_FORM('NO_VALIDATE');
execute_query;
END IF;
No compiling errors but Radio Buttons are not working. What I missed? Thank you.
I believe your CLEAR_FORM('NO_VALIDATE'); is sending the cursor to the control block, then your execute_query is executed in the wrong block.
Try using CLEAR_BLOCK('NO_VALIDATE'); if clearing the fields is really necessary.

Xcode: he first view doesn't see changes made by the second one

I'm a very newbie in the obj-c programming and have some troubles trying to change values between two views. I'm using Xcode 4.5 and storyboards and I've some problems with passing a changed value from the second view to the first one.
Here's my 2 very simple views (posting the link as I'm a new user and can't post images):
https://www.dropbox.com/s/q4o2bblu1p57zod/img.png
These views are assigned to the same class (ViewController) and the code I'm using to change the 2 labels is:
-(IBAction)setLabel:(id)sender
{
if (myTextField.text.length != 0) {
myLabel1.text = myTextField.text;
myLabel2.text = myTextField.text;
}
}
The problem is that Label1 changes correctly its text, but there's nothing to do with Label2! It doesn't want to change...
I think I'm trying to do something that can be made in others ways...Can you please tell me if it's correct?
You need to use Protocol-Delegate approach to update content in First view.
I suggest you to visit this sample link.
Your two view controllers may be of the same class but they are going to be different objects at runtime. You have a segue between them and when that executes a new instance will be created. Since the 'label2' of the second instance is not displayed on its screen, your assignment doesn't produce a visible change.

JQgrid:Get the action from the pager

how can i get the action (what button was clicked) when a button is clicked in the pager?(edit, del, add...)
You probably means button of the navigation bar or navigator (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator).
You can implement what you want with at least three different ways:
You define your custom buttons which look like the original add/edit/del buttons (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons) and use {add:false, edit: false, del: off} parameter of navGrid to switch off standard buttons.
You can use addfunc, editfunc and delfunc if you want replace the default add/edit/del functions.
You can use onclickSubmit or afterSubmit or some another supported events (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#events) of add/edit/del button to do some additional action on click the buttont or on submit.
You can chose the way which is the best for your requirements.
You can use the grid onPaging event:
This event fires after click on [page
button] and before populating the
data. Also works when the user enters
a new page number in the page input
box (and presses [Enter]) and when the
number of requested records is changed
via the select box. To this event we
pass only one parameter pgButton
(string) which can be -
first,last,prev,next in case of button
click, records in case when a number
of requested rows is changed and user
when the user change the number of the
requested page.requested page.
Also there are beforeRequest and LoadComplete events. Examples that worked for me are as follows:
beforeRequest: function () {
$.blockUI();
//alert("before request");
},
loadComplete: function () {
//alert("load complete");
$.unblockUI();
}