I want to copy the text in DialogBox in my clipboard from code after button click.
I need in my dialog a button with function ctrl+c .
I have this code for my Dialog:
Dialog dialog;
DialogField dialogField;
str string;
;
dialog = new Dialog("My personal dialog");
dialogField= dialog.addFieldvalue(extendedTypeStr(String30), string, "insert the text to be copied");
// ctrl + c button
//I need a button with the function to copy the text entered
dialog.run();
if (dialog.closedOk())
{
}
}
Thanks for help,
enjoy!
Check the TextBuffer.fromClipboard method.
Example use:
TextBuffer txtb = new textBuffer();
#define.ExampleFile(#"c:\test.txt")
#define.ExampleOpenMode("w")
// Set code access permission to help protect the use of TextBuffer.tofile
new FileIoPermission(#ExampleFile, #ExampleOpenMode).assert();
if ( txtb.fromClipboard() )
{
// Got text from clipboard - save it to file
txtb.toFile(#ExampleFile);
}
// Close the code access permission scope.
CodeAccessPermission::revertAssert();
It should be easy to adapt to a dialog.
Related
I have two questions:
1- I have a project that contains 5 forms, So I want to know how to return to the first form when closing the 5th form.
2- I have two buttons, one is visible on the form and the second one is not. What I wanted to do is to display the second button when the first button is clicked.
I added this code on the Form_load event: btn2.Visible= false, and I added this code under btn1_Click: btn2_Visible=true, but it didn't work. Can anyone help me please?
Form4 newform = new Form4(TextBox1.Text,TextBox2.Text);
newform.Show(); // this code is in form1.
this.Hide();
Then I created a button in Form4 to create Form 5 using the same code:
RForm Form5 = new RForm(Label1.Text, Label2.Text);
this.Hide(); // this is in Form 4
Form5.Show();
To return to Form1, I created a button in form5 :
private void c_Button_Click(object sender, EventArgs e)
{
this.Close();
Set the Parent property of your forms. For instance, to open Form4,
Form4 form4 = new Form4();
form4.Parent = this; // Reference to current Form1 instance
this.Hide();
form4.Show();
In the event handler in Form4, check for the parent property and show that.
(form4.Parent as Form1).Show();
this.Close();
You would also want to handle the Closing event if user closes the form any other way than your button.
For the second part, as long as event handlers are wired up properly, this should work. In the event handler, btn2.Visible = true would work.
I'm new to JavaFX. I want to create Listener which calls question dialog when user closes a tab into the TabPane. So far I managed to create tabs dynamically and add some custom configuration.
tabAvLabel = new Label(ss);
tabPane.getTabs().add(0, tab); // Place the new tab always first
tabPane.getSelectionModel().select(tab); // Always show the new tab
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); // Add close button to all new tabs
I don't know what event listener I need to use and how to define it. Would you show me how to implement this?
You can try onCloseRequest for Tab class
tab.setOnCloseRequest(new EventHandler<Event>()
{
#Override
public void handle(Event arg0)
{
//your code
}
});
Try this code :
tabAvLabel = new Label(ss);
tabPane.getTabs().add(0, tab); // Place the new tab always first
tabPane.getSelectionModel().select(tab); // Always show the new tab
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); // Add close button to all new tabs
tabPane.getOnClosed(), setOnClosed(new EventHandler<Event>(){
#Override void handle(Event e){
// What you have to do here
}
})
For more information, see http://docs.oracle.com/javafx/2/api/javafx/scene/control/Tab.html#onClosedProperty
I've hacked a similar support you have in jdk8 support into 2.2 (https://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.e4.controls.fx2/src/org/eclipse/fx/e4/controls/fx2)
The answer of #VagrantAI can work. But you have to add the following codes on your 'OK' button click action function:
stage.fireEvent(
new WindowEvent(
stage,
WindowEvent.WINDOW_CLOSE_REQUEST
)
);
While the problem of this approach is the event is triggered when you click 'X' to close the window too. This should not be the purpose normally.
To solve this, add a flag (or static variable) in the class that loads the window. So every time the window is loaded, set the flag to false. When the window is closed, set the flag only when the 'OK' button is clicked. Then you can do your action regarding the value of this flag.
In my XUL application, I open a dialog window, by this code:
var win = myWindow.openDialog("chrome://mywindow/content/mydialog.xul",
"Dialog creation",
"chrome, dialog, modal, resizable=yes",
params).focus();
And I access the information passed by user, by this code:
if (params.out){
dialogVariablesValues = params.out['inputValues'];
sameDialog = params.out['sameDialog'];
(...)
}
When the OK button in the dialog window is clicked, the window is closed, the if (params.out) becomes true and I can get the values. I don't have any problem with this approach. The problem is that I need to change my dialog window to be dependent. So I have changed the code to:
var win = myWindow.openDialog("chrome://mywindow/content/mydialog.xul",
"Dialog creation",
"chrome, dialog, dependent, resizable=yes",
params).focus();
But params.out is always null...
Does anyone know how I can get the values when the dependent dialog is closed?
With a dependent dialog the execution continues after the openDialog() call even though the dialog is still open. So you want your code to be "notified" when that dialog is closed. The easiest solution should be passing a callback in the params and changing the dialog to call your callback when it is closed. So the code opening the dialog would look like this:
params.callback = function(inputValues, sameDialog)
{
// Do something with the dialog result here
};
myWindow.openDialog(..., params).focus();
And the dialog would have code like this:
var inputValues = ...;
var sameDialog = ...;
window.addEventListener("unload", function()
{
// Dialog is being closed, call the callback
window.arguments.callback(inputValues, sameDialog);
}, false)
I'm using an OpenFileDialog to let the user chose a file to open.
it works, but if I chose a file and insted of pressing OK I press CANCEL it still opens the file because I picked up one.
I found this code in the MSDN, but I can't see ::DialogResult::OK in my apllication
if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
// Insert code to read the stream here.
myStream->Close();
}
}
my code is:
fileD1->ShowDialog();
while(!fileD->FileName->Lenght!=0)
{
}
and here I open the file
any other idea of how to know which button I pressed?
I'm using c++ and visual studio 2008
save the return of this ->> openFileDialog1->ShowDialog()
into a value and then check the value
DialogResult::OK
or
DialogResult::CANCEL
I have a modal dialog box presented in Yahoo UI. The user selects a value from dialog "A", and then I want to present another modal dialog box to collect some more data in dialog "B".
I have been using the YAHOO.widget.Dialog successfully. The problem seems to be that you can't initiate dialog window "B" from the handler function of dialog "A". So, how can you programmatically launch a second dialog window after the user hits the "OK" button on the first ?
(I had tried to create an additional Listener for a field that is updated in dialog "A" to trigger dialog "B" but this doesn't work either.)
Thanks..
Check out the documentation: http://developer.yahoo.com/yui/container/dialog/#events. The following code should do the trick:
var firstDialog = new YAHOO.widget.Dialog('firstDialog', { postmethod: "manual" });
firstDialog.manualSubmitEvent.subscribe(function (type, args) {
var nextDialog = new YAHOO.widget.Dialog('nextDialog', { });
/* more configuration stuff... */
nextDialog.render();
nextDialog.show();
});
firstDialog.render();
firstDialog.show();
This handles when the form is to be submitted, which I think what you mean by selects a value, but if not let me know and I can give some help on that situation.