Using "Button" from Toolbox in Vector Panel Designer, for a CAPL - can-bus

I am writing testcases in CAPL and want to activate each test case by using "Button" from Panel Designer.
The problem is that whenever I pressed the Button, it reacted as if it were pressed twice.
I just simply add a code like this to make that problem visible.
(The system variable of "#sysvar::Test_Cases::TC1" is linked to the Button in the Panel Editor)
on sysvar sysvar::Test_Cases::TC1
{
putValueToControl("Window","CAPL Output View",#sysvar::Test_Cases::TC1);
}
I expect to see only --> Value of #sysvar::Test_Cases::TC1 =1
But the output is like this:
Value of #sysvar::Test_Cases::TC1 =1
Value of #sysvar::Test_Cases::TC1 =0

on sysvar X{...} event procedure reacts to value change of X.So in case of button press (0->1) value will be set to one then on button release (1->0) value will be set to zero, so you change the value of X twice. This is why you are getting trigger twice.
To react only once on such button press event, and get notification only once, please use the keyword this and condition statement.
on sysvar sysvar::Test_Cases::TC1
{
if (this==1) /* Following block is called only once, on button press 0->1 */
{
putValueToControl("Window","CAPL Output View",#sysvar::Test_Cases::TC1);
}
}

Related

Get keyboard show event in Unity3d

I am making a game in unity3d for iPad only.
In one screen I need to take text input from user and for that I use Input Field.
I need to make some UI change when user open keyboard by taping Input Field. For that I need keyboard open(show) event. Input Field give me just two event 1. Text Change 2. Lost Focus. But I need get Focus event.
I read official document but can't find any relevant event. I search on internet for event, I get keystroke event but I need keyboard open event before user start typing.
In native iOS app we use UITextFieldDelegate Method - (void)textFieldDidBeginEditing:(UITextField *)textFieldor UIKeyboardDidShowNotification. Is there any way in Unity3d to get this kind of behaviour.
For input field with the new UI there is an isFocused variable.
http://docs.unity3d.com/ScriptReference/UI.InputField.html
http://docs.unity3d.com/ScriptReference/UI.InputField-isFocused.html
#pragma strict
// Required when Using UI elements.
public class Example {
public var mainInputField;
function Update() {
//If the input field is focused, change its color to green.
if (mainInputField.GetComponent.<InputField>().isFocused == true) {
mainInputField.GetComponent.<Image>().color = Color.green;
}
}
}
So if your field gets focused and it returns true you can execute some code. That is, if I understand you correctly.
I can't find anything that lets you know the InputField has been selected but a workaround may be setting the Interactable property to false and having an 'Edit' button near the field. When the 'Edit' button is pressed, you can change the UI elements and set the InputField.interactable = true.

Advancing control focus in a VCL TFrame

I have a TFrame on which some TEdits are placed. These edits are
boxes for serial key input, as I'm trying to setup a user experience
where input focus jumps from one edit box to the next, when a certain amount of
characters been entered in each. That is, user do not need to press tab
or click on the next edit in order to advance.
I found an example in the C++ Builder HowTo book (great book) on how to
"simulate" enter press to behave like a tab press in edits and was
trying to employ the same technique. However, something in my app don't
work as in that example.
In the frames KeyPress event, I have the code
void __fastcall TAboutFrame::Edit1KeyPress(TObject *Sender,
System::WideChar &Key)
{
TEdit* theEdit = dynamic_cast<TEdit*>(Sender);
if(!theEdit)
{
return;
}
if(theEdit->Text.Length() >= 6)
{
//jump to next edit
Perform(WM_NEXTDLGCTL, 0, 0);
...
But the 'jump' to next control does not occur.
The main Form, the frames parent, do have key preview == true and I can
set a breakpoint to see that the Perform call is indeed executed.
The tab orders on the edits are 1,2,3,4,5.
I wonder if this has todo with TFrames messaging or?
If the controls you are using descend from TWinControl (Which they should if you are using stock VCL controls), You can also use TWinControl->SetFocus() to explicitly set the focus to the desired control.

combobox steal keyboard from main window in pyqt

I'm writing a small pyqt program. I want the main window to to react to arrow movement. I added an event to my MainGui class, keyPressEvent, that handle this. The event work fine as long as I don't press certain buttons such as Key_Up or Key_Down are directed to my (currently only) QComboBox and not to my mainGui. I tried to give the focus to mainGui after each paintEvent but then I need to double click on buttons/comboBox.
Then I tried to use the MousePressEvent to check if a certain element is under the mouse. This work fine with the comboBox, but not with the button.
So, how can I direct key events to the mainGui or give the focus to QButtons?
I used eventFilter to identify when the mouse enter the QPushButton and give it focus:
def eventFilter(self,source,event):
if event.type() == QtCore.QEvent.HoverMove:
if self.execButton.underMouse():
self.execButton.setFocus()
self.keepFocus=False
else :
self.keepFocus=True
keepFocus is a flag I initialized in the __init__ function of the class. I added this part at the paintEvent function
if self.keepFocus:
self.setFocus()
else:
self.keepFocus = True
Now, I keep the focus at the MainGui and I only give it to the button when the mouse hove over it. If I do another action (like pressing a mouse button or a keyboard key) the focus is given back to the MainGui. This will create some buggy filling (For example, I need to press twice a keyboard key before the first response) but this is workable.

Disable keyboard shortcut (delphi)

I created a form in Delphi.
Say I have a Form with a speedbutton with label "&Add" (underline A, as a keyboard shortcut), and a dbgrid (read-only state) (or other control like TButton).
Then I changed the focus to Dbgrid (dbgrid got a focus) (or to TButton).
Every time I press the a key on the dbgrid, the onClick method on the speedbutton triggers.
Sometime I need to disable it for a while for a reason, and then i enable it again.
How to disable the speedbutton shortcut?
And then how to enable it again?
The form is pressing the button when you press A because the button has expressed interest in that key, and nothing else on your form is accepting keystrokes. If you had an edit box on your form, and it had the input focus, then the button would not be triggered.
You can make a control indicate that it wants to receive keystrokes when it has the focus, but that generally happens when writing a custom control, where you have some idea of what the new control class should do when it receives keyboard input.
If you don't want the button to be triggered, you can disable it. Another option is to alter the OnClick event handler to check other conditions (such as whether the grid has focus) before performing the usual click-handling code.
You could disable the shortcut by changing the speed button's label from &Add to Add. Change it back when you need to enable the shortcut again.
Please note that specifying an accelerator character like that enables two shortcuts, one is just the key prefaced with the & and the other the same key with Alt. So, in your case they would be A and Alt+A. In the same way, eliminating the accelerator disables both shortcuts. So, keep in mind that with this method of disabling the shortcut you would be unable to trigger the button neither with A nor with Alt+A.

How to remove click handler in windows phone 7?

In a page one image control is there.when click on that i am showing big image.in some condition i don't want to show.For that i am trying to remove click handler event.please tell me how to remove image mouse enter click event in wp.
You can remove a event handler from a event by using the -= operator.
Example for removing a event handler called OnTap_Handler from the Tap event of a Image.
Image.Tap -= OnTap_Handler;

Resources