Determine which button is clicked/button

Hi guys, I have a question of n00bish (and more to come sorry)

I created an array of buttons (i.e. the name of the buttons are: buttonDelete [0, 1, 2,... etc])

so they FieldChangeListener for each button.

Currently, I made choice of 10 buttons (generated with loop for) and 10 FieldChangeListeners

10 FieldChangeListeners seems to be very inefficient, so my question is:

can I make a table of FieldChangeListeners so that if a button is pressed, correct FieldChangeListener used?

Thanks in advance!

You can have a single FieldChangeListener assigned to all 10 buttons. Then in the listener, you can test which button has been activated and send to the appropriate action:

FieldChangeListener listener = new FieldChangeListener() {
    public void fieldChanged( Field field , int context ){
        if (field == buttonDelete[0]) {
            // respond to button 0
        } else if (field == buttonDelete[1]) {
            // respond to button 1
        } // etc.
    }
};

It's very ugly. Depending on your needs, you may be able to reduce this to a loop for.

There is an approach much more if you can set up your logic button - in other words, if you can set the response so all buttons do the same treatment, only on different data. To do this, you can use setCookie/getCookie:

FieldChangeListener listener = new FieldChangeListener() {
    public void fieldChanged( Field field , int context ){
        process( field.getCookie() );
    }
    private void process( Object data ) {
        // process the data stored as a cookie in the activated button
    }
};

Object[] cookies = {
    // array of data that parameterizes button processing logic
};
for (int i = 0; i < 10; ++i) {
    buttonDelete[i] = new ButtonField( ... );
    buttonDelete[i].setChangeListener( listener );
    buttonDelete[i].setCookie( cookies[i] );
}

Tags: BlackBerry Developers

Similar Questions

  • Check which button is clicked

    I have four buttons on the frame one. When one of the buttons is activated, it then goes to two glory. There is not much difference between what the buttons do: addition, subtraction, multiplication and division. Ideally, the program would be

    (1) check which button is clicked
    2) go to section 2
    (3) according to the which button has been clicked frame 1, make an addition, subtraction, multiplication, or division

    I have a few questions

    (1) is there a simple way to check which button has been clicked? I guess you could have different function calls in the function addEventListener for each button and then write a different function for each button. But I was wondering if there is a way to do it with if statements? This means that the same function is called in addEventListener for each button, press function controls which button triggered the function call. The code below shows what I would do (including pseudocode).

    (2) how do I pass a variable of framework one part two? Here I could have 4 frames separate (one for each arithmetic operation), but I prefer not to have that one frame and pass the exact operator (+, -, *, /) to frame two and have then framework both make an addition, subtraction, multiplication or division according to operator was passed.

    You add to that more than complexity it takes probably, but I don't see the whole picture, so I'll cover a little.

    You can use the events received by the function to determine which button was clicked:

    var btnClicked:String;

    function fnSolve(event:MouseEvent):void {}
    btnClicked = event.target.name;
    }

    btnAdd.addEventListener (MouseEvent.CLICK, fnSolve);
    btnSubtract.addEventListener (MouseEvent.CLICK, fnSolve);
    btnMultiply.addEventListener (MouseEvent.CLICK, fnSolve);
    btnDivide.addEventListener (MouseEvent.CLICK, fnSolve);

    I don't know why you want to go to frame 2, but that's fine. You don't need to pass a variable to two of the frame, just to extend your actionscript layer up to now and whatever variables live in frame 1 are available in the frame 2 automatically.

    The part of the function if() of this function could be moved to the 2 structure, if the function frame 1 would only need to be really...

    function fnSolve(event:MouseEvent):void {}
    btnClicked = event.target.name;
    gotoAndStop (2);
    }

    and in part 2, you would have...

    If (btnClicked == "btnAdd") {}
    Add stuff
    } Else if (btnClicked == "btnSubtract") {}
    subtract stuff
    } else if... etc.

  • What is the best way to determine which line a user has clicked on a link?

    Hello. Question no doubt simple, but my googleing fails me. I have a table with a column that is a command link. How can I determine which row was clicked on? I need to take this value and to move to another page to link it to a different query. I thought to establish the result in a session bean? Or is there a better way?

    Thank you!

    Hello

    You have two options:

    1. (complex) have your ActionListener evaluate the event to get the source, then climb the tree of components up to the table and get the data of the current line;
    2 (single) add a setPropertyActionListener in relation to the value = "#{var}" target = "#{destination}" where var is the value of the attribute of the var and destination table is your bean managed requiring the line clicked.

    Kind regards

    ~ Simon

  • Advanced action scripts - y at - it a variable that tells me which button is clicked?

    Lilybiri gave me some great tips on the use of conditional tip action scripts. Now, I have another related question.

    I have three buttons A, B and C. Each button performs exactly the same series of actions to hide everything on the page, but shows another group of objects depending on which button was clicked - that is, to display the Group A and Group B group C.

    Currently, I have a separate advanced action script for each button (in fact a lot more than three) because of this difference, then want to combine in a single conditional script. However, I can't understand how I would like to know which button was clicked.  In other words, I think that my conditional script should look like this:

    The condition "always."

    If 1 is equal to 1

    [Script to hide all]...

    Continue

    Condition 'has '.

    If MyButton is equal to 'A '.

    See the group_A

    On the other

    Continue

    Condition 'B '.

    If MyButton is equal to 'B '.

    See the group_B

    On the other

    Continue

    Condition 'C '.

    If MyButton is equal to 'C '.

    See the group_C

    My problem is that I don't know how to set or get the value of MyButton to perform conditional tests. Is there a system variable that returns the value of a selected object? I looked at all the variables, and I don't see one. Or y at - it another way to do what I'm missing?

    You probably can find with Javascript, but not with advanced actions. All the available system variables that can be used - there are more - are in a table that you can download here: System variables in Captivate 8 - Captivate blog

    I have several articles on the shared use of stocks. You apply the same instance of a common action several times and don't have that to indicate parameters, in your case these parameters will be for most groups and objects. I hope that stocks shared will expand more in the future. They have several advantages: given that you use multiple instances of the same action that they do not increase the file size as duplicate advanced actions. In addition, you have them in the library that makes management much easier.

  • With the help of A6, must create menu screen which allows the user to click a button creates a branch to other screens and return to the main menu. When returning to the main screen on which button will be gray or inactive.  How can I do this?  I created

    I am trying to imitate a piece of equipment.  I need the user to be able to click on the specific buttons that have the user to another or screens.  After viewing these screens that will be the user to the main screen where the user which buttons were pressed and which still needed to be pressed.  I create buttons image with the 3 States - who has worked except when the user returns to that slide is reset to zero, and if the user does not see the 3rd State of the button.  How can I get this 3rd State of stay after the user returns to the main screen?

    You can not 'keep' a State, that's what I said in my first answer: "you can create an image with that look of '3' State, make it invisible and show it with the same action when a button is triggered. You will need to insert extra that third picture, first hide it out and make it visible to the advanced action, which I explained. I called this additional 'Done_one' image in the example. The three States you're talking about are in a totally different way to Captivate: for down, more and up-state. You can just tell Captivate to keep a low State, it will be down when the button is pressed. Where my explanation of an additional image.

    No need for all the variables. Looks like you have a lot to learn about variables and advanced actions. I don't see another easy way to achieve what you want. It is not so difficult, tons of examples on my blog.

  • Detect which button was selected from a message popup dialog box

    I'm sure I've done this before and don't remember how I did it.

    I even searched the forum for messages but did not find any.

    I have a popup message asking if a number was on.

    It has two buttons "YES" & "

    I want to know which button has been selected in order to assign a pass/fail for the LED Test result.

    How to achieve this?

    R

    Step.Result.ButtonHit

    There will be 1 or 2 or more if you have more than 2 buttons

    Omar

  • Which button F # I hit for a start to the top of the disc?

    Try to reinstall windows XP.  I did before, he is asked to restart from the disc and I forgot which button I push on reboot.  Thanks for the help.


  • How can I determine which applications and processes are turned on at first upward and how can I keep their autostart?

    My office of gateway using Windows XP takes a long time to start.  I hear a lot of activity because it starts and after a very long time, I can really use it.  I would like to know what process or applications start automatically and then determine which ones to move away and how.

    If you were to Google something like:

    XP boot manager

    You will get hits with links to managers of free starter like this simple:

    http://www.MLIN.NET/StartupCPL.shtml

    Another popular and free tool with a built-in startup manager (and other interesting things) are CCleaner which you can download here:
    http://www.Piriform.com/CCleaner

    CCleaner allows you to manage most of the startup items and also do some other operations oriented cleaning.  Some people will you recommend is not to use the registry functions in CCleaner to avoid these features for now.  I have no problem with it for me, but sometimes it's a contentious issue, I prefer to avoid as much as possible!

    You can uninstall CCleaner later if you don't like it.

    You can disable the startup items, see how things look and if you want - you just delete them (or leave it off).

    After launch of CCleaner and see what startup items you can disable/remove, if you are still not sure of your startup items, follow these steps:

    Run CCleaner and choose Tools, boot and bottom right, click on the button "Save to text file" to save the startup information in a text - something like startup.txt file

    Save the boot information text file on your desktop (or somewhere you can find it) open the text file with an editor (Notepad or WordPad), select all (Ctrl-A), copy text, all the text selected in the Windows Clipboard (Ctrl-C) and then paste (Ctrl + V) the contents of the startup list to come back here in your next reply and maybe someone can tell you another thing to consider.

    A more revealing startup Analyzer is Autoruns which will allow the manipulation of all sectors of boot and does not actually install anything:
    http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspx

    I have zero startup items on my computer, so none of this is important to me!

  • HP Pavilion changeable: need help determine which laptop to buy

    I was hoping that somoene could help me determine which laptop is the best for me

    I have a powerful desktop computer, so I have no need for anything either super madly fancey-shmancy
    I really just want something that I can take with me on a business trip and inspired as I ask myself in bed

    I was watching the 13s (?) HP Pavilion x 360 convertible laptop
    Basically, I need a touchscreen laptop that can include:

    • Support a PRESSURE of the STYLUS pen
    • A kind of mode you can activate for that screen ONLY takes the stylus input.

      (Think if you draw on a sheet of paper, your hand is placed on the paper, but you're only drawing in pencil)

    And until someone offers Wacom - Yes, I have a Wacom tablet, I love it - but it is so awkward while your eyes focus on the monitor of drawing with your hand. The only other option would be to spend about $1300 for the Wacom tablet, I'd be interested - and WHY do that if I can buy a laptop touchscreen that serves more than one purpose?

    Hello

    Your MAIN one being styluscondition, I check an other way around and there is a list of (computer) HP produucts who can use HP pen/stylus

    http://h20386.www2.HP.com/AustraliaStore/merch/product.aspx?ID=J4R51AA&opt=&SEL=ACC

    Kind regards.

  • I was looking in my information system; software environment; system drivers and I noticed that many have stopped status. How can I determine which are to be started? How can I start them?

    I was looking in my information system; software environment; system drivers and I noticed that many have stopped status.  How can I determine which are to be started?  How can I start them?

    Hello

    · Do you see a problem with your computer?

    You can check the links which has more information on the information system: Description of Windows XP system information (Msinfo32.exe) tool: http://support.microsoft.com/kb/308549

  • How to determine which program to use to open files and programs?

    Help!

    How can I determine which program opens a file or another program?

    I constantly get the message that xxxxx will not open this file. / Select a program to open this file/etc.

    Hi marco47,

    You want to get this prompt either if there is no program installed on the computer that opens the file type or you have not associated any program to open this type of file.

    See the link below to find out how to associate any type of file or Protocol with a program to open the file.

    Change the programs that Windows uses by default

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-which-programs-Windows-uses-by-default

    See the Microsoft article below and run the fixit tool to reset the associations of files on the computer.

    When you run an .exe on a Windows Vista-based or Windows 7 computer file, the file may start another program

    http://support.Microsoft.com/kb/950505

    I hope this helps!

    Halima S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to determine which files can be repaired by the System File Checker tool

    Original title: results of scan now

    I have scan now it says I have corrupted files, how to know what they are

    Hi Honey bunch,

    To determine which files can be repaired by the System File Checker tool, analyze the file journal program SFC.exe (System File Checker) generates. Follow the steps mentioned in the article below

    How to analyze the entries in the log file generating the program Checker (SFC.exe) resources of Microsoft Windows in Windows Vista

    http://support.Microsoft.com/kb/928228

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Determine which user added an ESX host to vCenter

    I'm trying to figure out if there is anyway to determine which user has added a vCenter ESX host using the api.  I don't see this information as any sort of property of the host object.  Any help would be appreciated!

    Paul

    You can retrieve this and other events by using the event manager and the queryEvents() - http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.event.EventManager.html

    There is no property associated with a host ESX (i) on which the user added to vCenter and since it seems that you are interested in a specific host ESX (i), which can help narrow down the query.

    Attached, that is, remove / add a vSphere SDK for Perl script that will return the user who added the host to vCenter, you should get a response because it uses the Ref object managed the host ESX (i) and that changes each time you have.

    Here is an example of course:

    ./findUserAddHost.pl--serveur root vcenter50-4 - vihost - vesxi50 - 3.primp username - industries.com
    Enter the password:
    added root host vesxi50 - 3.primp - industries.com to datacenter datacenter2

  • determine which host is running a virtual machine

    We can go in the computer virtual guest operating system, directly determine which host running the VM?

    # Only way is to connect to vCenter from inside the virtual machine and see it with vSphere client or powershell.

    ---

    MCSA, MCTS, VCP, VMware vExpert 2009

    http://blog.vadmin.ru

  • OIM:how I can determine which user has ' revoke if applies "set

    IOM how can I determine which users have "revoke if applies" defined on any of their policies? I can't see where it is set on the policy itself, but this setting appears to follow user not politics. I want to say, if I apply a policy to a user, even if this flag is set, then turn off the flag and remove the policy from the user, the resource is always cancelled even if politics is going not to do. I need to find in the database this setting (strategy/user) storage so I can't disable it on all users who still have on any of their policies.

    Thanks for any help at all (including links to docs so I can find this for me).

    There is a POL_KEY on the Oud_ table and the table of OUEDRAOGO. You can try to understand something here.

    -Kevin

Maybe you are looking for

  • Plist missing mail

    On a MBP upgrade Sierra retina I was getting no audio alert when I did the update that made me go and look at the prefs. and here there was no plist for Mail just a 'shared '. (I have no idea how long this has been the case). So, what should I do to

  • Window.OnUnload does not work as expected.

    My scenario. In the vicinity of the browser / tab / refresh the tab to run the piece of code. All my code is window.onbeforeunload who used to work in the previous version of firefox. But with the latest code version runs only on closing the tab, but

  • Cannot remove security file Carbon Copy Cloner in El Capitan

    OS X on Macbook Pro 10.11.2.  I dragged Net Carbon Copy Cloner file to the trash and tried to empty the trash.  I get a series of error messages indicating that the various files may not be emptied because they are currently in use.  I tried to empty

  • White screen on Canon PowerShot HS SX60

    White screen in fashion, work in the photo, including menu review shooting

  • DRAC6 connect and then immediately disconnect

    I provide a name of user and password in the login window, click on submit.  The normal menus appear on the side of left hand and above, but then I am immediately disconnected, return to the login screen. Because I can not connect I do not know how t