Modal Stage isResizable - tornadofx

For TornadoFX 1.7.0, is there anyway to make a fragment not resizable when it is opened as a Modal?
I would like to make the modal not resizable so you cannot maximize or change the size of the dialog in any way.
There is no isResizable option in the open modal option
fragment.openModal(isResizable = false)

The current best way to do this is from the onDock callback of the UIComponent:
override fun onDock() {
modalStage?.isResizable = false
}
The reason for this is that if you add block = true, your callback wouldn't complete until the modal dialog closes, so it would never kick in.
I just committed an optional resizable parameter to openModal() and openWindow() so that you can do this more conveniently from TornadoFX 1.7.1:
fragment.openModal(resizable = false)
It is already committed, so you can play with it in TornadoFX 1.7.1-SNAPSHOT if you want :)

I'm not sure if it's the best way to do it (Edvin can tell you when he answers), but you can just use
fragment.openModal()
fragment.modalStage?.isResizable = false

Related

Set readonly field only first line (Kendo UI)

I'd like to set readonly field, but only first line on the grid. How can I do this?
Any suggestions are welcome!
You can make use of the edit function like
edit: function(e) {
//add your custom logic here as if condition
//as for this example it just disable the one with id 1
//or maybe ada a new attribute like isEditable = boolean upon datasource.parse then check it
if (e.model.id == 1) {
//revert edited cell back to `read` mode
this.closeCell();
}
}
Well this is not exactly prevent opening, its just immediately close it after it opened i think. but it is viable option since i cant even see the changes. Working example dojo and this actually sugested in the kendo forum here

Nativescript Android - hide keyboard

In my Nativescript app, the application starts with the login page. On iOS everything looks good, but on android, the username field is focused and the keyboard is showing. Is there a way to prevent this from happening?
So far I have tried:
Getting a reference of another element (a label) and calling lbl.focus() in the page's onLoaded event
getting a reference of the username textfield and calling txt.dismissSoftInput() and txt.android.clearFocus()
None of this worked. Is there another way to hide the keyboard when the page is loaded?
Thank you
I guess the username field is either textview or textfield. If so, try this on loaded callback:
var myTextview = page.getViewById("myTextView");
myTextView.dismissSoftInput();
So I ended up implementing a different solution. This may not be the best approach, but it serves its purpose in my case and I wanted to share it for those of you that face a similar scenario.
in page's loaded event I included this code:
if (page.android) {
var un = page.getViewById('username');
var p = page.getViewById('password');
un.android.setFocusable(false);
p.android.setFocusable(false);
setTimeout(function () {
un.android.setFocusableInTouchMode(true);
p.android.setFocusableInTouchMode(true);
}, 300);
}
The key here is the setTimeout function (Thanks Emil Oberg for pointing me to the right direction). As far as I understand, here is what is happening:
The page loads and we call setFocusable(false) on the only 2 text fields to prevent Android from setting the focus on them
Then we wait 300ms to allow Android to do its initialization
When the timeout executes, call setFocusableInTouchMode(true) to allow the fields to gain focus.
At this point the page is loaded without any fields to be in focus and with the keyboard hidden. If the user taps any of the fields the keyboard will appear and they can proceed to log in as usual.
As I mentioned, this may not be the best, or correct, approach, but works for me. Hope this can save someone the time to research the issue.
You want to clear the focus of the field in the loaded callback:
var searchBar = page.getViewById('my-search-bar-id');
if (searchBar.android) {
searchBar.android.clearFocus();
}
What about combining both tips above?
onClear(args) {
const searchBar = <SearchBar>args.object;
if (isAndroid && searchBar.android != undefined){//avoid random unpleasant error
setTimeout(() => { // the key here was this timeout
searchBar.android.clearFocus();
}, 1)
}
}

How can I remove the default onCancel confirmation prompt in CKEDITOR dialogs?

When using ckeditor links, images and table properties dialogs if the user clicks on cancel, CKEDITOR will check if anything has changed and if so prompts the user with js confirm popup.
How can I disable this prompt on cancel; no other dialogs in our webapp prompts on cancel and this is not consistent.
There doesn't' seem to be a way to get a list of all the handlers for an event to remove the one that's doing the prompt.
I don't want to specify a custom isChanged for each and every dialog item to hack a fake nothings changed.
Is there a standard way to override the base on('cancel',...) event handlers in CKEDITOR? I see that I can monkeypatch the dialogdefinition.OnLoad, OnOK, OnCancel handlers but this forced cancel prompt I'm referring to is not being done in the dialog's OnCancel.
I'm using the latest version 4.2
This is now a supported configuration option in version 4.3. Just specify config.dialog_noConfirmCancel = true when you create the dialog.
Check out http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-dialog_noConfirmCancel
You where very close. In fact it is in fact is the onCancel event.
There is a ticket for this problem that also includes a workaround:
CKEDITOR.on('dialogDefinition', function(dialogDefinitionEvent) {
if (dialogDefinitionEvent.data.name == 'link') {
var dialogDefinition = dialogDefinitionEvent.data.definition;
// Get rid of annoying confirmation dialog on cancel
dialogDefinition.dialog.on('cancel', function(cancelEvent) {
return false;
}, this, null, -1);
}
});
If you leave out the if (dialogDefinitioNEvent.data.name == 'link') statement it would disable the check for all dialogs.
The -1 handler parameter is the key here, as it inserts the handler before the dialog plugin's default handler, which will never be invoked because the return false cancels the bubbling of the cancel event to the other registered event listeners.
CKEditor Ticket #8331: Ability to ignore "Confirm Cancel"-warning on dialogs
I can confirm that the latest version of ckEditor works with the "noConfirmCancel" attribute.
A snippet of my working code is as follows:
<script type="text/javascript" src="#ckBasePath#/ckeditor.js" language="JavaScript"></script>
<script>
thisConfig = CKEDITOR.config;
thisConfig.autoParagraph = true;
thisConfig.fillEmptyBlocks= true;
thisConfig.dialog_noConfirmCancel = true;
objSample = CKEDITOR.replace( 'Sample' , thisConfig);
</script>
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-dialog_noConfirmCancel

Scriptaculous Autocomplete list closes on scroll bar click

I have a really annoying issue with Autocomplete with Prototype 1.6. I set up and dialog-style div with a form, which contains an Autocomplete. Everything works fine until I click the scroll bar, or drag it; it closes the list of suggestions. I checked this solution but now I got an javascript error
event.srcElement is undefined
I was checking the controls.js and tried to catch the event object inside the onBlur event, but it travels empty. Printed the offsetX property and is undefined. Looks like the event doesn't exist anymore. either way, it prevents that the list closes but, If I click outside the area, the list now doesn't close. And that's kinda of issue too
Anyone with this same issue? Any idea?
Thanks in advance
I was having the exact issue yesterday, but after doing some r&d I got a pretty handy fix for this.
By default this script was hiding the result div (Suggestion List) on the blur event on the search text box so as soon as we click on result div's scroll bar focus gets lost from input element & result div closes. So I did a small edit in controls.js to change the behavior of script, so now result div close method doesn't invoke on blur (focus out) from input element but triggered on the click on the document except the text input element.
For your convenience I've put the edited controls.js here.
If you like to know what has changed in JS file, here it is;
Added a event listener to the document. Just below this line
"Event.observe(this.update, "keypress", this.onKeyPress.bindAsEventListener(this));"
Event.observe($(document), "mouseup", this.onMouseup.bindAsEventListener(this));
Added a new onMouseup method.
onMouseup: function(event) {
if(!this.hasFocus) {
this.hideTimeout = setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
this.active = false;
}
},
Modify the onBlur method (Comment out two line in block)
onBlur: function(event) {
//this.hideTimeout = setTimeout(this.hide.bind(this), 250);
//this.active = false;
this.hasFocus = false;
}
I hope this will solve your issue.
Thanks
Vinod Kumar

How to mimic stopPropagation using jQuery.live

So I know that one of the downsides of using jQuery.live is the unavailability of .stopPropagation(). But I need it badly.
Here's my use case. I have a checkbox is that is currently bound to a click. However, other checkboxes appear on-screen via an AJAX call, meaning I really need .live('click', fn). Unfortunately, the checkbox is situated atop another clickable element, requiring .stopPropagation(). This works fine with .bind('click', fn), but the inability to use it with .live() is hampering me. Using return false doesn't work as the checkbox will not be checked.
Any ideas on how to mimic .stopPropagation() when using .live() without returning false?
Instead of binding a .live handler to the checkboxes, bind a smarter event handler to the container, with behaviour dependent on which element is the target of the event.
$("#container").click(function(e) {
var ele = e.target;
if(ele.tagName.toLowerCase() == 'input'
&& ele.type.toLowerCase() == 'checkbox') {
e.stopPropagation();
// do something special for contained checkboxes
// e.g.:
var val = $(ele).val();
}
});
Here is something of an example to show how this can be used.

Resources