Radio button clicked twice in row return error - radio-button

I am using 5 radio buttons which when invoked it creates new widgets that are specific to each button. However, once widgets are created you cannot have the same widget created with the same path name or an error is displayed. The radio buttons are able to be clicked more than once which creates the error mentioned before. Is there anyway to either restrict pressing the same radio button twice in a row or keep the window from trying to be recreated?

use [winfo exists]. something like this:
radiobutton .r1 -text 1 -value 1 -variable radiovalue -command make_widget
radiobutton .r2 -text 2 -value 2 -variable radiovalue -command make_widget
pack .r1 .r2
proc make_widget {} {
global radiovalue
set name .widget_$radiovalue
if {[winfo exists $name]} {
puts "$name already exists"
} else {
pack [label $name -text $name]
}
}

You could disable the radio button that is pressed until another is pressed or you could delete the existing set of widgets if any before creating any.

Related

Validate if checkbox is checked depending on another validation in vuelidate

I'm just starting with Vue and vuelidate. I have a form which shall work in the following way:
The form shows a Yes/No radio button group.
If the radio button "Yes" is selected then the form shows a checkbox.
The submit button for the form shall be enabled if one of the following conditions is true:
The radio button is set to "No". OR
The radio button is set to "Yes" AND the checkbox is checked.
I'm having trouble with the conditions described in 3. My current validation looks like this:
termsAccepted: { checked: value => value === true }
This basically works for case 3.2 but not for 3.1. In that case the form is still disabled.
b-form-checkbox#termsAccepted(
v-model="termsAccepted"
:state="!$v.termsAccepted.$invalid"
:disabled="disableForm"
)
Thats sound like a computed property should to the job:
Computed Property Documentation
You could do something like:
computed: {
isEnabled() {
return !radiobutton || (radiobutton && checkbox.checked)
}
}

Selecting popup without title and clicking button inside it with geb

I have a popup without title and I want to detect the window using any other criteria (for example a div that wraps the whole popup) and click a button inside it.
I've tried the following:
when:
withWindow({ $("div", class:"main.msgAlert" )}) {
$('#close').click()
}
then: true
But I always get a org.openqa.selenium.ElementNotVisibleException at te #close action.
Am I failing at detecting the window or is the error related to the button?

How to hide a button on an app with multiple windows? - Objective C OSX

I have an application which has a button on the first window, once pressed this button should hide and perform an action, to hide the button i'm using this code:
[self.myButton setHidden:TRUE];
This works fine until I have multiple windows - new instances of this window do not have this button it's hidden by default. However when I create a new window and press the myButton on the first window it doesn't hide the button.
Furthermore if I create a new window and then close that window and press the myButton on the first and now only window it crashes.
It's clear it always seems to target the last window created, how can I make it always target the first window created, or the window the action is actually being sent from?
New windows are simply being created by calling a newDocument from the document controller like so:
[dc newDocument:self];
Most button actions look like this:
- (void)someAction:(NSButton* sender) {}
or
func someAction(sender : NSButton) {}
As you can see, a sender is passed with the action. Now this sender is actually the button you pressed. So you can simply hide this particular button by calling sender.hidden = true;
The sender is automatically added when you use Storyboards or Xibs to add the actions.
If you add the action programmatically, add a colon after the selector (ObjC) or string (Swift). The button instance should be passed to you then.
... action:#selector(someAction:)...
or
... action:"someAction:" ...

XPages: how to create a dialog box with callback to the caller

I have an XPage with 2 custom controls. The 1st custom control has a repeat control and the second is used just as a dialog box.
The user can delete a row from the repeat control by clicking on a delete link. then i use rowVar.getDocument.getNoteID and i delete the document.
What i want is to ask the user first: "are you sure you want to delete it?"
I used "window.confirm()" in CSJS but i dont like the default prompt box. So then i used dojo dialog box but i cant use rowVar of repeat control in it to get the documentId.
Currently i have code in the OK button of the dialog but i want to use OK/Cancel buttons only as a true/false and execute the code in the main custom control. Is there a way of passing the value of the button back to the caller?
I have done this in many ways. Basically, write the information you need to find the document to delete to a viewScope variable. Then create a stand alone event handler that is called from the OK or Cancel buttons of the dialog.
So the eventHandler looks like this post by Jeremey Hodge:
<xp:eventHandler
event="onfubar"
id="eventHandler1"
submit="false">
<xp:this.action><![CDATA[#{javascript:
// write the ssjs to save the doc base on viewScope parameters
}]]></xp:this.action>
</xp:eventHandler>
Then the dialog buttons look something like this (based on the Mastering XPages book and many other sources):
XSP.partialRefreshGet("#{id:eventHandler1}", {
params : {action :"OK" },
onComplete : function () {
// do something else if needed
},
onError : function() {
alert("no soup for you!");
}
});

Dojo OnKeyPress Handler: TextBox value is blank

I have a Dojo form that does not contain a submit button. Instead, I added an onkeypress handler to calls a method when Enter is pressed. The problem I am having is that when I hit enter before blurring off the current field, the _process method thinks that field is empty.
Or in other words: type in field1. hit tab. type in field2. hit enter. field2 is blank unless i click off the field or shift-tab back.
Any ideas?
dojo.connect(dijit.byId("fkrform"),"onKeyPress",function(e) {
if (e.keyCode == dojo.keys.ENTER) {
_process();
}
and the method it calls:
function _process()
{
var field1 = dijit.byId("field1").value;
var field2 = dijit.byId("field2").value;
alert(username);
alert(password);
...do stuff...
}
The fields are of dojoType: dijit.form.TextBox, and the form is: dijit.form.Form
Use dijit.byId('field1').get('value') instead of directly try to access the property "value". In your example you saved the value in the variable field1 and field2 and in the alert you use the variable username and password could be the answer why you don't get anything. But you still should use the get method to get a property instead of directly access the property.
When you press "Enter" your form will submit. So you need to connect to the "onSubmit" event on the form, instead of onkeyPress or onKeyUp.
The first example i created prints the value of the input box on every key someone pressed in the console.
http://jsfiddle.net/a8FHg/
But what you really wanted was hooking into the submit. I modified the example. The new example connects to "onSubmit" and creates an alert box with the text of the user input.
http://jsfiddle.net/a8FHg/1/
For completness if jsfiddle doesn't work some day. You JavaScript should looks like this.
dojo.ready(function(){
var form = dijit.byId('form');
var box = dijit.byId('box');
var submit = function(event) {
dojo.stopEvent(event);
alert("User input was " + box.get('value'));
};
dojo.connect(form, 'onSubmit', submit);
});
Assuming your form in your HTML has the id form and your box have the id box.