Random Godot beginner-question: en-/disable CheckButton - button

how can I enable or disable a CheckButton via code? Is there any simple way like "input pickable true/false" I use with collision shapes? I played around with control focus modes but didn't succeed.
For example: I'd like to have a timer starting when button down / holding down and after a certain time the button shouldn't react at release anymore. Just as if it was never put down in the first place...
There must be a simple command for that, right?
Edit:
Trying
my_button.disabled = true
leads to the error
Invalid set index 'disabled' (on base: 'GDScriptNativeClass') with value of type 'bool'.

It sounds like you're looking for the pressed property.
my_button.pressed = true
The documentation isn't very clear on the usage but it does what you're describing. https://docs.godotengine.org/en/stable/classes/class_checkbutton.html

Related

Looking for example of how to display text in an NSWindow programmatically?

I am trying to display text in a HUD style semi-transparent window. I have got the code for the window all set up, but I have been scouring the documents for two days now and haven't come up with a way that works to actually display text in the window. Since I am using AppleScriptObjC in Script Debugger, and not Xcode, I'd rather do this programmatically and not have to switch to Xcode and use IB. (I did spend some time messing around with IB, but it is not very intuitive to be honest. So I thought I would check this form before going through the guides on how to get started using IB).
So I was given some advice to "create an NSTextField and add it to your window's contentView". So I have tried many different set ups of trying to init a NSTextField (And NSTextView), and I may have been able to get that part correct, but getting the text to actually display in the window has been a bigger challenge than I expected. I have included a code snippit of the code I am using to generate the window.
tell (NSWindow's alloc()'s ¬
initWithContentRect:{{theWidth, theHeight}, {640, 480}} ¬
styleMask:NSBorderlessWindowMask ¬
backing:NSBackingStoreBuffered ¬
defer:true)
setOpaque_(yes)
setAlphaValue_(0.5)
setBackgroundColor_(NSColor's grayColor())
setReleasedWhenClosed_(yes)
setExcludedFromWindowsMenu_(yes)
orderFrontRegardless()
delay 1
|close|()
end tell
My hope is to be able to get an NSText View in that Window in order to display some text in it. So far I haven't come close. The errors I generally get are about "unrecognized selector sent to instance". So it is pretty obvious that I am doing something wrong. I hope there is an easy way to accomplish this that I haven't yet come across.
It sounds like there isn't a target for some of the methods. In a tell statement, usually the target is implied, but sometimes AppleScript can't figure it out. You also don't get the newer method syntax, so I've had better luck just specifying the target for everything - also note that object properties can usually be set directly instead of using their setter method.
I can't tell from your snippet, but you also need to add the textView to the window's contentView, for example:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
# create a text view
tell (current application's NSTextView's alloc's initWithFrame:{{20, 20}, {600, 440}})
set theTextView to it
end tell
# create a window
tell (current application's NSWindow's alloc()'s ¬
initWithContentRect:{{200, 600}, {640, 480}} ¬
styleMask:(current application's NSBorderlessWindowMask) ¬
backing:(current application's NSBackingStoreBuffered) ¬
defer:true)
set theWindow to it
set its opaque to true
set its alphaValue to 0.5
set its backgroundColor to (current application's NSColor's grayColor)
set its releasedWhenClosed to true
set its excludedFromWindowsMenu to true
end tell
theWindow's contentView's addSubview:theTextView
theTextView's setString:"this is a test"
theWindow's orderFrontRegardless()
delay 5
theWindow's |close|()

Is it possible to show all options in Tokenize2?

Tokenize2 is a javacsript lib to select multiple options.
It provides a very neat UI to start writing and then get a list of options to select from. Selected options will show up as "tags" that can be removed with "x" link.
So far all is fine. But Right now you need to know what your looking for and start write at least one character to see matching alternatives.
In my scenario there are very few alternatives and they are not known to the user. I would like to show ALL options when the user clicks the input box. There is a configuration option named searchMinLength but it is already set to 0.
Is there a workaround that can be used? Maybe like triggering load and dropdown manually?
I know there are a lot of similar alternatives but I picked Tokenize2 because:
It looks clean and nice
It works in mobile browsers
I don't know if there is an "official" approach, but after some investigation I have found an acceptable workaround.
After downloading the Tokenizer2 sourceode I found the following line that triggered my attention:
if(this.input.val().length > 0){
this.trigger('tokenize:search', [this.input.val()]);
}
My interpretation is that the internal search command is not triggered unless the user input has at least one character. This line in sourcecode could easily be modified. I have filed a suggestion for this here: https://github.com/zellerda/Tokenize2/issues/26
My current workaround is to add an event listener for the select event and there trigger the internal search command. That works fine for my scenario and does not force a source code rewrite.
$("#my-dropdown").on("tokenize:select", function (e: Event, routedEvent: boolean) {
$("#my-dropdown").trigger('tokenize:search', "");
});
Tokenize2
This link worked for me GitHub
$('.tokenize-sample-demo1').on('tokenize:select', function(container){
$(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
});

How to write the manual AutoLayout constraint?

I'm a novice iOS developer and I want to learn how to write the manual AutoLayout constraint. As I had found the link which visually allow how AutoLayout works. Please refer the below link for more information.
URL : https://autolayoutconstraints.com/
But it does not allow how it works when other component over there and their relation accordingly.
Thank you for such a prompt response, I wish I could be clearer on my issue.
I suppose by manual you mean apply constraints via Code.
Autolayout has been constantly evolving ever since it come to existence.
To apply constrains via code, you can use any of these three techniques. (Easiest and the newest technique at bottom)
Old verbose constraining using method, (constraintWithItem)
+(instancetype)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(nullable id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c
Visual Format Language
(https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html)
Layout Anchors (https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html#//apple_ref/doc/uid/TP40010853-CH16-SW5)
You can google the bold's to know more.
But these is nothing better than https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/index.html#//apple_ref/doc/uid/TP40010853-CH7-SW1
This document has examples that apply constraint, with other component (view) and their relations.
are you asking how to set up your constraint programatically? If yes do you plan on using the story board at all or implementing everything programatically?
if you want to do it all programatically it would look something like:
class someViewController: UIViewController{
let myLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Hello"
}
override func viewDidLoad() {
super.viewDidLoad()
view.addSubView(myLabel)
myLabel.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
myLabel.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
myLabel.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
myLabel.heightAnchor.constraint(equalToConstant: 50).isActive = true
}
}
This would create a label in your ViewController and pin it to the left right and bottom with a set height of 50 pixels. You can find any one of your constraints for the item by looking for it's anchor and setting it to the desired value. Make sure to set translatesAutoresizingMaskIntoConstraints to false otherwise your constraints won't be followed.
You can use a 3rd party library like Snapkit or SwiftyLayout.

Vimperator: Follow hint in new tab and switch to it

I am trying to find a strategy in the Vimperator-logic for opening a link to a new tab and switch to it immediately.
I guess this might be a TMTOWTDI.
My first approach would be to start off with a :command sequence. Unfortunately F - Follow hint in background tab - has no equivalent in the command mode. The best solution for me would be without any change in default behaviour whatsoever.
Another approach might be to combine the default F with switching to next tag gt. This would have to include to pass the parameter for F, say 10 for the tenth link of the document. Unfortunately F10gt does open the tenth link but without switching to the newly opened tab.
A third approach does come to mind when using focus elements: ;y10 yank the destination link, :tabopen + paste clipboard content.
Any ideas of what is doable and the easiest?
This functionality exists as a mode of the hint function. Pressing ;t
will produce the desired result. If you want to map it you can also access the javascript directly.
:js hints.show("t")

How to view Session Variables in Visual Studio 2008 Debugger?

Usually using Visual Studio's debugger is a breeze. Scanning through Locals quickly shows the values of variables, etc. However, I'm at a loss how to find out the values contained in session state variables? Can anyone give me a hand?
Let's say I put a breakpoint right after:
Session["first_name"] = "Rob Roy";
How do I view the value contained in Session["first_name"] from locals?
It's pretty simple to inspect the session during debug. Just put a breakpoint in your code and just highlight your Session code (eg. highlight: Session["first_name"]) then right click and select QuickWatch....
This will setup up a watch on your Session for the value you had defined. You can also inspect other Session elements by adjusting the Expression field in the QuickWatch window and clicking the Reevaluate button.
In VS you can just put 'Session["first_name"]' in the Immediate Window and execute while the code is running. That will return the value that it holds.
If you can't find it go to: View > Other Windows > Command Window, or press Ctrl+W, A
It will look like this:
I know its a bit of a late reply but for anyone else who is interested, I hope this helps!
Isn't it HttpContext.Current.Session("..."), I ask as I haven't used ASP.NET for a long time.

Resources