AS 3: event handeling
I thought sending a var directly to the event handeler would
work but i was wrong. How can you adjust/conditional a function so
that when one button is clicked it does one thing and the other
another?
Check out all the stuff that is in the MouseEvent. There is a
target property that tells what was clicked on. So:
trace(event.target);
Similar Messages
-
Key down event handeling when the VI isn't active
Hi
I've written a simplel VI that increases or decreases a numerical indicator depending on which key is pressed on the keyboard. But this only works when the VI window is active (the titlebar is blue and not gray). Is there anyway to listen for the key-down event even though the VI is not active?
In advance thanks
GeorgI recently ran into a problem with the Acquire Data.
See http://forums.ni.com/ni/board/message?board.id=170&message.id=147363
Just in case.... -
Ok I know the difference between low level and schemantic events. But, what if I want a component that is supposed to use schemantic events to use a low level event? Her is the deal, I have a JList that has a ListSelectionListener. I used it, but it doesn't do what I want. I want to lisen for a double click. If I use a mouse event, which seems my only option, the I have to use a low level event that listens for a double click anywhere on the frame, and not just attached to the JList. If that is the case, then does that mean I have to write code to tell where the double click occured and if it were in the list then handle it, if not then ignor it? Is there no way to attach a low level event to a specific component instead of having it listen to all components on the frame, as well as the frame itself? But, if I could do that then it wouldn't be a low level event, right?
You could just use the mouse listener to find the possition of the mouse, and check to see if it's within the rectangle that the component is located in.
-Jason Thomas -
Event handeling variable changes. Is this possible?
Hey,
I'm working on a java-beans project and I am trying to come to find a way to signal an event when a variable changes. Basically looking for a way to constantly send the refreshing data to the listener bean.
I can easily get it to work send the data with pushing a button but this is supposed to monitor a constantly changing temperature and send it to the listener bean.
Any ideas?
Thanks.Use Timer or ur own Thread.
-
Hi,
In the controller I have created an event and a method to fire it. In the view, I need to create a "handleControllersEvent" event handeler, but I cannot subscribe the event from the controller because the dropdown is empty.
What is necessary (or what have I missed) so that the events from the controller are visible in the subscribed event ddlb when creating an event handler in a view.
Note: I am using the popup dialog tutorial as a referenence for my application.
Thanks for the input.
Regards,
faBHi faB,
open your view, go to "Proprties", press "Add" and add your cotroller.
Regards, Maxim R. -
Firing keydown event from software`
I would like to know how to fire a keydown or mousedown etc. event from the program itself. Without actually pressing the keys or buttons.
Something to do with dynamic event programming?Dynamic events are one of the best features added to LV 7.0 and have saved me a few times. The idea is that you can add events which an event handeler can register for the only thing you have to do it decide on the parameters which define the event. basically you craete a user event, register for the event, pass the event to the dynamic event terimina (right click on the event structure and "show dynamic event terminal" then add the event case just as you do with a native event. In addition you can turn on and off the dynamic events as needed. I will post an example I did later if it would help. Spent the time to learn dynamic events, well worth the effort.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA -
Hello,
Could anyone let me know if the filter for an event inside the
workflow be dynamically set , be it a JMS Event or Plugin Event ?
Thank You.
SangeethaDynamic events are one of the best features added to LV 7.0 and have saved me a few times. The idea is that you can add events which an event handeler can register for the only thing you have to do it decide on the parameters which define the event. basically you craete a user event, register for the event, pass the event to the dynamic event terimina (right click on the event structure and "show dynamic event terminal" then add the event case just as you do with a native event. In addition you can turn on and off the dynamic events as needed. I will post an example I did later if it would help. Spent the time to learn dynamic events, well worth the effort.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA -
How to get attribute values from one view to another
HI all,
Thx in Advance..
I have 2 view like v1,v2.In v1 i used one attribute values from "get single attribute" method.And i need the same values in v2 screen.For this i did in v1 outbound plugs , i mentioned the parameter name . How can i get the same values in v2.Hi chandru ,
you said you declare the parameters in the Outbound Plug of V1. now go to view V2 inbound plug Tab and creat one inbound plug
double click on the plug name .it will navigate you to the event handeler method . Now add the outbound parameter variables in the
parameters
For example : V1firing the navigation plug
a type string " defined in parameter
wd_this->fire_out_to_view2_plg(
a = 'ABCD' " string
you can retrive the value freely in v2 inbound event handeler
a type string " defined in parameter
* set single attribute
lo_el_context->set_attribute(
name = `TEXT`
value = a )." here you will get the 'ABCD'.
regards
Chinnaiya P
Edited by: chinnaiya pandiyan on Jun 23, 2010 7:12 PM -
How to raise error message from PAI of oops ALV report
Hi All,
I have a requirement to raise error message form editable oops alv . After entering the data and then press SAVE button .
Please help.
Thanks in AdvanceHI SK,
Write a Local class (Event Handeler) to handel the events. In Editable ALV once the user enter a value, CL_GUI_ALV_GRID will raise an event called DATA_CHANGED.
1. Define and Implement a local class to handle that event.
In the implementation of this class you need to get data from imported object to an internal table, then compare the same with the ALV output table.
* Local Class to handler the events raised from the ALV Grid
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
* Method to handel EDIT event, DATA_CHANGED of CL_GUI_ALV_GRID
METHODS : ON_DATA_CHANGE FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED.
ENDCLASS.
* Event handler class Implementation
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD ON_DATA_CHANGE.
DATA : LT_MODIFY TYPE LVC_T_MODI,
LS_MODIFY TYPE LVC_S_MODI.
* Copying changed data into intenal table from Object
LT_MODIFY = ER_DATA_CHANGED->MT_MOD_CELLS.
* Modifying the ouptut table with the changed values
IF LT_MODIFY[] IS NOT INITIAL.
*Compare the ALV Output table with LT_MODIFY
ENDIF.
ENDMETHOD.
ENDCLASS.
Then raise a message on required condition in the same method.
Note: To trigger the above method, you need to set event handler before displaying ALV (before calling method SET_TABLE_FOR_FIRST_DISPLAY)
* Creating object for the Local event handler class
CREATE OBJECT GR_HANDLER.
* Set handler (call method of Event_handler) to handler Edit event
SET HANDLER GR_HANDLER->ON_DATA_CHANGE FOR GR_GRID.
Regards,
Vijay -
New to swing: Error while using getText() in ActionPerformed
Hi there!
I'm fairly new to java and swing, and this problem I'm having drives me nuts!
// Imports //
public class Generator extends JFrame {
// Graphical components
private JTextField nr1;
private JTextField nr2;
// Constructor
public Generator() {
// Call superclass
// Init variables
JTextField nr1 = new JTextField(2);
JTextField nr2 = new JTextField(2);
nr1.setVisible(true);
nr2.setVisible(true);
// Layout stuff..
// Create listner-object for event handeling
Lyssnare minLyssnare = new Lyssnare();
playerName.addActionListener(minLyssnare);
clear.addActionListener(minLyssnare);
shuffle.addActionListener(minLyssnare);
// closing of window
// Pack
// Visible
// Action Listener
class Lyssnare implements ActionListener {
public void actionPerformed(ActionEvent ae) {
// Some other actions...
// Shuffle
else if(ae.getSource() == shuffle) {
String teams = nr1.getText();
String players = nr2.getText();
Shuffle.shuffle(name);
playerArea.setVisible(false);
int teamsint = Integer.parseInt(teams);
int playersint = Integer.parseInt(players);
error1.setVisible(true);
}The error I get is after "else if(ae.getSource() == shuffle) {"
something on the next line (and the line after that) is the one who gives the error...
I Get this (during running, compile works fine..):
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
AFAIK that means I'm reffering to something that is null... but how can that be when all the textfields are initialised? do I have to make does fields global in some way?
Grateful for any help!Your inner class does not have access to nr1 and nr2 because they are not final variables.
Instead of creating an inner class Lyssnare, you can have your Generator class implement the ActionListener and add the actionPerformed method inside Generator class as follows:
public class Generator extends JFrame implements ActionListener {
// Graphical components
private JTextField nr1;
private JTextField nr2;
// Constructor
public Generator() {
// Call superclass
// Init variables
JTextField nr1 = new JTextField(2);
JTextField nr2 = new JTextField(2);
nr1.setVisible(true);
nr2.setVisible(true);
// Layout stuff..
// Create listner-object for event handeling
//Lyssnare minLyssnare = new Lyssnare();
playerName.addActionListener(this);
clear.addActionListener(this);
shuffle.addActionListener(this);
// closing of window
// Pack
// Visible
public void actionPerformed(ActionEvent ae) {
// Some other actions...
// Shuffle
else if(ae.getSource() == shuffle) {
String teams = nr1.getText();
String players = nr2.getText();
Shuffle.shuffle(name);
playerArea.setVisible(false);
int teamsint = Integer.parseInt(teams);
int playersint = Integer.parseInt(players);
error1.setVisible(true);
} -
How to add the REFRESH button in OOPs ALV grid
how to add the REFRESH button in OOPs ALV grid
Hi Naidu.
Check the below code:
Local Class Definition and implementation For events handeling
CLASS LCL_EVENT DEFINITION .
PUBLIC SECTION.
METHODS :TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT,
USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
ENDCLASS.
CLASS LCL_EVENT IMPLEMENTATION.
METHOD TOOLBAR.
WA_TOOL-FUNCTION = 'ZFC1'.
WA_TOOL-TEXT = 'TEST'.
WA_TOOL-ICON = '@EA@'.
APPEND WA_TOOL TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "DISPLAY
METHOD USER_COMMAND.
IF E_UCOMM = 'ZFC1'.
ENDIF.
ENDMETHOD. "USER_COMMAND
ENDCLASS. "LCL_EVENT IMPLEMENTATION
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZALV_BTON'.
SELECT * FROM VBAK INTO TABLE GT_VBAK
UP TO 30 ROWS.
**** CREATE CONTAINER OBJECT
CREATE OBJECT MY_CONTAINER
EXPORTING
CONTAINER_NAME = 'CC1'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6 .
****** GRID TO CONTAINER
CREATE OBJECT ALV
EXPORTING
I_PARENT = MY_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5.
CREATE OBJECT OBJ.
SET HANDLER : OBJ->TOOLBAR FOR ALV.
SET HANDLER : OBJ->USER_COMMAND FOR ALV.
****** ALV DISPLAY
CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
CHANGING
IT_OUTTAB = GT_VBAK[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
* text
MODULE USER_COMMAND_0200 INPUT.
IF SY-UCOMM EQ 'BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0200 INPUT
Regards
Kumar M -
MSS Employee Search integration
Hi,
I have developed some ABAP WebDynpro applications and now I want to integrate them with the MSS team viewer (Employee search) iView i.e. when an employee link in the team viewer is clicked, the pernr of the selected employee should pass to my iView.
Can someone suggest me how to achieve this.
Thanks in advance. Will reward points for gunuine answer.
Regards
MukeshHi John,
I am also doing the same thing.but the control is not going to the event handeler method.and it is not subscribing to the event also i guess.
below is the code i have written in the View of my component WDOINIT.
l_api_component = wd_comp_controller->wd_get_api( ).
l_portal_manager = l_api_component->get_portal_manager( ).
DATA l_wd_view TYPE REF TO if_wd_view_controller.
l_wd_view ?= wd_this->wd_get_api( ).
CALL METHOD l_portal_manager->subscribe_event
EXPORTING
portal_event_namespace = 'urn:com.sap.mss.employeesearch'
portal_event_name = 'SELECTION_CHANGED'"'selection_changed'
view = l_wd_view
action = 'SUBSCRIBE_TO_EVENT'.
and the event handeler code is :-
method ONACTIONSUBSCRIBE_TO_EVENT .
DATA: evt_name TYPE string.
DATA lo_nd_gc_event_data TYPE REF TO if_wd_context_node.
DATA lo_el_gc_event_data TYPE REF TO if_wd_context_element.
*DATA ls_gc_event_data TYPE wd_this->element_gc_event_data.
DATA lv_event_string TYPE string.
evt_name = wdevent->get_string( name = 'PORTAL_EVENT_NAME' ).
IF evt_name = 'selection_changed'.
lv_event_string = wdevent->get_string( name = 'PORTAL_EVENT_PARAMETER' ).
get single attribute
*lo_el_gc_event_data->set_attribute(
*EXPORTING
*name = `EVENT_STRING`
*value = 'handled' ).
ENDIF.
endmethod.
I don't know why it is not triggering the handeller method.
Can you please help me by the steps how you did this.
Thanks
Ankur -
Observable and ActionListener.. help
Is there anyway to pause update method and continue after I click the �Add Student� button?
The update method is called automatically when my observable object is changed, so I can�t display previous observable information via the button�s ActionListener.
Anyway to do that?
Thanks
import java.util.Observable;
import java.util.Observer;
import java.awt.event.*; //package for event handeler
import java.awt.*;
import javax.swing.*;
public class Lab5Frame extends JFrame implements Observer {
private JLabel label;
private String name;
public TestFrame(Observable observable) {
System.out.println("Windows created.");
observable.addObserver(this);
public Lab5Frame(String title) throws HeadlessException {
super(title);
Container c = getContentPane();
JPanel panel = new JPanel();
label = new JLabel(name);
panel.add(this.label);
JButton button = new JButton("Add Studnet");
button.addActionListener(new ListName());
c.add(button, BorderLayout.NORTH);
c.add(panel, BorderLayout.CENTER);
//*** window adapter
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
private class ListName implements ActionListener{
public void actionPerformed(ActionEvent event){
//what should I write here to performe the updated information
vai the update method?
//oberver update
public void update(Observable arg0, Object arg1) {
System.out.println("LogConsole: " + arg1);
}Is there anyway to pause update method and continue after I click the �Add Student� button?
The update method is called automatically when my observable object is changed, so I can�t display previous observable information via the button�s ActionListener.
Anyway to do that?
Thanks
import java.util.Observable;
import java.util.Observer;
import java.awt.event.*; //package for event handeler
import java.awt.*;
import javax.swing.*;
public class Lab5Frame extends JFrame implements Observer {
private JLabel label;
private String name;
public TestFrame(Observable observable) {
System.out.println("Windows created.");
observable.addObserver(this);
public Lab5Frame(String title) throws HeadlessException {
super(title);
Container c = getContentPane();
JPanel panel = new JPanel();
label = new JLabel(name);
panel.add(this.label);
JButton button = new JButton("Add Studnet");
button.addActionListener(new ListName());
c.add(button, BorderLayout.NORTH);
c.add(panel, BorderLayout.CENTER);
//*** window adapter
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
private class ListName implements ActionListener{
public void actionPerformed(ActionEvent event){
//what should I write here to performe the updated information
vai the update method?
//oberver update
public void update(Observable arg0, Object arg1) {
System.out.println("LogConsole: " + arg1);
} -
Matrix actions and linking the Matrix-row to some fields
Hello every One,
I would like to have the following "action" ! I have a Form where i puted 2 edit fields and 1 matrix (Screen Painter), the matrix shows me the first and lost name of the Employee ( just an exp.).
What i would like to do is to send these datas to the edit fields every time i choose another row. i cannt find any itemEvent for the raws to select the record in the data base and to bind it to the edit Fileds! is this a good way to do it ??
Thank You for every helpHi Amir
You can use the et_GOT_FOCUS event to check for focus on the Cells of the Matrix. I recommend using et_GOT_FOCUS because this will facilitate mouse and keyboard navigation.
When you capture the event on the Matrix check the pVal.Row to get the row that received the Focus. Using this Row index retrieve the data from the Matrix and set the values for the required edit fields.
<i>Remember to include event et_GOT_FOCUS in your EventFilters</i>
<b>Event Handeling Example:</b>
If pVal.BeforeAction = False Then
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_GOT_FOCUS Then
'IDH_MTR - Matrix Item
If pVal.ItemUID = "IDH_MTR" Then
Dim oMatrix As SAPbouiCOM.Matrix
oMatrix = oForm.Items.Item("IDH_MTR").Specific
'Work with the DataSources of the
'Edit Fields to avoid triggering the
'Focus events again.
' * ED1 and ED2 is the DataSources for the
' Edit Fields
' * Column(1) And Column(2) contains the data
' that will be copied to the edit fields
oForm.DataSources.UserDataSources.Item("ED1").Value = oMatrix.Columns.Item(1).Cells.Item(pVal.Row).Specific.Value
oForm.DataSources.UserDataSources.Item("ED2").Value = oMatrix.Columns.Item(2).Cells.Item(pVal.Row).Specific.Value
End If
End If
End If
I hope this will help -
Help, need to add a delete button to my application?
i have a little application that you can add numbers and friends email too
i would like to add a minus selection/entry button?
do any of you guys have any ideas?
stop();
//create a new sql connection
var conn:SQLConnection= new SQLConnection();
//add an event handeler for the open event
conn.addEventListener(SQLEvent.OPEN, openHandler);
//create the database if it doesn't exist, otherwise just opens it
var dbFile:File =File.applicationDirectory.resolvePath ("exemplu.db");
conn.openAsync(dbFile);
function openHandler(event:SQLEvent):void {
//create a new sql statement
var sql:SQLStatement=new SQLStatement();
//set the statement to connect to our database
sql.sqlConnection=conn;
//parse the sql command that creates the table if it doesn't exist
sql.text= "CREATE TABLE IF NOT EXISTS contacte(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"nume TEXT, " +
"telefon INTEGER)";
//add a new event listener to the sql when it completes creating the table
sql.addEventListener(SQLEvent.RESULT,retrieveData);
//call the execute function to execute our statement
sql.execute();
function retrieveData(event:SQLEvent = null):void {
//create a new sql statemant
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection=conn;
//this sql command retrieves all the fields from our
//table in the database and orders it by name
sql.text = "SELECT id, nume, " +
"telefon " +
"FROM contacte ORDER BY nume";
//add a new event listener if there is data
//to display it
sql.addEventListener(SQLEvent.RESULT, selectHandler);
sql.execute();
function selectHandler(event:SQLEvent):void {
//first we clear our list
lister.removeAll();
//the we create a result variable that holds
//all our contacts
var result:SQLResult=event.target.getResult();
//we check if results is not empty
if (result!=null&&result.data!=null) {
//and we add a new item to our list for
//each contact in our database
for (var i:Number = 0; i < result.data.length; i++) {
lister.addItem ({ label:result.data[i].nume + "-" +result.data[i].telefon
, nr:result.data[i].id });
plus.addEventListener(MouseEvent.CLICK,adder);
xu.addEventListener(MouseEvent.CLICK,closeapp);
back.addEventListener(MouseEvent.MOUSE_DOWN,drag);
//because my buttons are not real buttons
//but movieclips i need to set the
//buttonMode property to true
plus.buttonMode=true;
xu.buttonMode=true;
function adder(e:MouseEvent):void{
//remove the eventlistener and move to the
//next frame
plus.removeEventListener(MouseEvent.CLICK,adder);
nextFrame();
function closeapp(e:MouseEvent):void {
//close the application
NativeApplication.nativeApplication.exit();
function drag(e:MouseEvent):void {
//drag the application
this.stage.nativeWindow.startMove();
this is on the second key frame-
//this line restricts the user input
//to just numbers in the phone input box
//add a new event listener to our plus button
plus.addEventListener(MouseEvent.CLICK,adder2);
function adder2(e:MouseEvent):void {
//create a new sql statement variable
var sql:SQLStatement=new SQLStatement();
sql.sqlConnection=conn;
//the next sql command creates a new entry
//in the table contacte from our database
sql.text = "INSERT INTO contacte(nume, " +
"telefon)" +
"VALUES(@nume, " +
"@telefon)";
//to insert variables into sql commnads
//we use the parameters definition
sql.parameters["@nume"]=nume.text;
sql.parameters["@telefon"]=tel.text;
//add a new event listener that calls the
//function that retrieves the data
sql.addEventListener(SQLEvent.RESULT,retrieveData);
sql.execute();
//go to frame no. 1
prevFrame();
//remove the eventlistener from our plus button
plus.removeEventListener(MouseEvent.CLICK,adder2);use:
minus_btn.addEventListener(Event.MouseEvent,CLICK, clear)
function clear(e:MouseEvent){
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = conn;
var s:String = "DELETE from contacte WHERE nume= :numeparam AND telefon=:telefonparam";
sql.text = s;
sql.parameters[":numeparam"] = whatever;
sql.parameters[":telefonparam"] = whatever else;
//add listeners if you want
sql.execute();
Maybe you are looking for
-
Using OID Authorisation in APEX
Hi, One of my colleagues (much more skilled in APEX than me) has written a package that makes it easy to use Oracle Internet Directory (OID) groups to control access to pages and items. It assumes that you are already using Oracle Single Sign-On (whi
-
BizTalk Administration Console problem after installing IBM iSeries Access
Hi, We have a Biztalk Server 2010 environment on Windows Server 2008 R2 with SQL server on separate machine. After installing IBM iSeries Access we get errors in Biztalk Administration Console, especially the Host Instance and Adapter information c
-
Just had 10 cards printed from iPhoto image (with text added) to test quality. Really pleased with the result and would like to order a lot more, but without the whole process of redesign. Is there a simple way of re-ordering an earlier order?
-
Touch Pad, mouse not working on lower 25% of screen
Have not seen this question, yet. When on a web page, my double tap/left click does not work on about the lower 25% of the page. The scroll arows work, but cannot click or type on the page if in the lower portion of the page. After scrolling up t
-
Help needed on a Payroll Extractor 0HR_PY_1_CE
Hi All, I am looking for the following information on a Payroll Extractor, as part of my project. - Currently we are using an extractor 0HR_PY_REC_51 in our project. - We intend to know if Payroll reconciliation with GL happens in the extract