Make sure current focus isn't textbox? - actionscript-3

I'm working on an application in Flex 3.2, and I need to be able to tell whether the current focus is a textbox or not. How would I go about doing this? There's more than one textbox in my application, so I can't really set multiple event handlers for focusOut, etc.
Thanks,
Matt

You can accomplish this by using the stage.focus property. It holds the instance of whatever object has the focus.
So in whatever spot you want to do the check, just do this:
if(stage.focus is TextField){
//do whatever you'd like to do
}
I'm not really a flex user, but I'm pretty sure the text components use TextFields inside them and that the focus will still be a TextField class. Someone please correct me if I'm mistaken.

Related

Action script 3.0 reusable button function

I am new to AS3.0 and am trying to create a reusable button class. I am working on a quiz game where I have multiple correct and incorrect buttons and instead of copying the same code over and over again I am trying to create a simple way to reuse the code. I am unaware how to do this. I have created various generic button classes and none have worked. I believe the best way would revolve around creating a generic class with a Boolean 'correct' and each button class extends this parent class and sets the correct Boolean true or false. In the parent class there would be a function saying if correct then go to next frame, if !correct go to lose frame. I have tried this but to no avail; any help?
If that's a design question, then no, a button should not know if it's "the correct one" in a given quiz. All logic should be handled by button's parents, whatever type they are. A simple design would do like this: Create a set of buttons with texts, then you addEventListener(MouseEvent.CLICK,someFunction) to each, where someFunction is one for the correct button, and another for wrong-answer buttons.

Visual Studio 2013 LightSwitch HTML Cascading Dropdowns

I'm currently helping a small team create a HTML LightSwitch business app that has a tier of 4 Cascading dropdowns. These drop downs are linked together just as the common example of when you select your state it filters to cities only in that state. However, the issue that we have run into is that upon changing one of the parent boxes the child box doesn't reset or revert to a blank state. How would it be possible to accomplish, if possible, the clearing the child boxes upon parent change. Im pretty sure we need an OnChange event handler but I'm not sure where to put this in LightSwitch because it creates the code for you.
Any idea's or code snippets that are able to fix this problem would be appreciated.
Thank you in advance for the help,
Jeremy
I think you need a change listener event on page created method screen.addChangeListener("DropDown1",DropDown1Changed);
function DropDown1Changed(e){
screen.findContentItem("DropDown2").value ="";
screen.findContentItem("DropDown3").value ="";
};
I havent tested this code. But, something similar to this should work. This should give you general idea about the solution.
Dont forget to remove the listener.
Use pop-ups based on Queries instead of drop-downs. Make the parameters for your queries optional where necessary. LightSwitch will then update the page definition as selections are made. This is because the binding of the popup data values is done at run-time, whereas the binding for controls rendered when the page loads is static.
Michael Washington gives a pretty good summary of the technique in this article.

Multiselect select element - capturing current option set before adding / removing new items

Hello and thank you for reading.
I have an aspx form hosted in SharePoint 2010 that has some multiple select elements within a form. There are buttons to add and remove options from these select elements.
My problem is that I need to run a query based on the options within these multi select elements each time new options are added / removed from them. SharePoint is executing some server side code I don't have access to but here's my underlying problem.
If I hook into the buttons' onclick event, when my function is called the options have already been added to or removed from the select element. I need to capture the current option set of these elements, before the onclick function executes.
Is there another event I can tie into? Something like onbeforeclick on the buttons or optionsChanged on the multi select element? It doesn't look like any event will satisfy what I need to do here, but I'm hoping someone has faced a similar issue before.
Thanks,
Zachary Carter
The only solution I could come up with is to capture the present set of options each time an option is added or removed.
This solution is going to involve alot of array manipulation however, and if I can avoid that and simply tie into an event, before the onclick event of the button is called, that would be my ideal solution.
This might not be a great answer to your question, and if not, I apologize. However, I just ran into a very similar problem, albeit using Visual Basic. The solution wasn't elegant in my eyes, but I used VB's MouseUp event, which fires when the mouse button is released. On release (i.e., at the end of the previous action), I save all the information in the elements into an array, and then on the next click, before anything else happens, I can check against that array.
Edit: Gah, looks like you posted essentially that solution while I was typing. Sorry I didn't notice.

java swing, simulate JTable terminateEditOnFocusLost behaviour

putClientProperty("terminateEditOnFocusLost", Boolean);
to make jtable end editing and clear current selected rows when it lose focus or when simply click over an other GUI component.
This is very useful, but with "terminateEditOnFocusLost" there are some strange behaviours if it is used with editCellAt and changeSelection.
There are also some undesiderable TableModelEvents fired for some fake table updates.
So, im looking for an hack to simulate "terminateEditOnFocusLost without using it, is this possibile?
Thanks all.
Overload the function to make it suit your needs.
No hack at this moment.
putClientProperty("terminateEditOnFocusLost", Boolean) seem to be the only correct way.

VBA Form update after values set in code instead of AfterUpdate()

I have multiple combo and option boxes whose visibility is set true or false depending on user selection of other parent option boxes.
I am using the AfterUpdate() function for the parent option boxes. This method has been working fine.
However when I set the values of the option boxes in VBA code (Me.MyOptionBox = 1), there is no "update" to make the child option and combo boxes appear. It works when I manually click on the option, but if I set it in the code nothing changes except for the option box selection. It doesn't make sense to see the option box set correctly but the code responsible for checking which option is selected not work.
Does anyone have any ideas on how to get around this? I just want the form to be updated once I set the values of the option boxes. What is the "update" that AfterUpdate() is referring to anyway?
I have tried MyForm.Repaint and MyForm.Requery but these do not work either.
Any ideas?
You can call the OptionBox_AfterUpdate() method directly - after you set the values.
I'm pretty sure this is intentional. The problem is avoiding circular recursive updates, when you consider that a control can be changed by a user and by two forms of code (explicit and bound data).
For bound controls, changes in the data change the controls.
For user input, changes in the control change the data, plus whatever dependendencies you explicitly specify in events.
For changes caused by your code, the assumption is that you need to manually apply all the consequences of the state change you are coding.
If you are using bound controls, you can change the datasource and have the consequences applied automatically.
In VBA, most control events do not fire when the control is updated programmatically, rather than manually. You must specify the code that is to run after the programmatic update.
By "I am using the AfterUpdate() function," you mean you added an event handler for the AfterUpdate event, right?
If that handler is not firing when you expect it to, you could always call your handler directly (instead of letting the event fire it) where necessary. But that probably wouldn't be the best way of doing it; more likely there is another event that should be calling your handler instead of or in addition to AfterUpdate. I don't remember the names of combo box events, but isn't there something like ItemChanged or SelectionChanged or something?