LIBGDX : setPasswordMode not working - libgdx

So I am building a game in LibGDX (Kotlin) and trying to setup a username and password field.
I create my TextField
password = TextField("", Gui.skin)
I set
password.isPasswordMode = true (Kotin changes setter and getters, under the hode this is calling setPasswordMode)
However the text still appears when I enter it in the box. I am using LibGDX 1.9.6

setPasswordMode will enable the password display mode of a text field.
How it works is that it replaces each character with a predefined character.
By default, this is the bullet "•", which some fonts may not have.
Change the password character to something else your font does have, like "*" for example:
password.setPasswordCharacter('*')
Note that you cannot do
password.passwordCharacter = '*'
because there is no corresponding getPasswordCharacter method, so no Kotlin property is generated.

Related

Scala Play 2.4.x handling extended characters through anorm (MySQL) to Java Mail

I was under the impression that UTF-8 was the answer to everything :0
Problem: Using Play's idiomatic form handling to go from a web page (basic HTML Text Area Input field) to a MySQL database through the Anorm abstraction layer (so all properly escaped) and then reading the database to gather that data and create an email using the JavaMail API's to send HTML email with alternate characters (accented characters like é for example. (I'd post more but I suspect we might get strange artifacts here as well -- I'll try that in a comment below perhaps)
I can use a moderate set of characters and create a TEXT email (edited via Atom and placed into the stream directly at the code level) and it comes through as an email with all the characters I've chosen in tact.
I have not yet systematically worked through the characters I was just using a relatively random sampling as an initial test.
I place the same set of characters into a text field and try to save them to the database and I can only save about 1 in 5 or less of them.
The errors look like this:
SQLException: Incorrect string value: '\xC4\x93\x0D\x0A\x0D\x0A...' for column 'content' at row 1
I suspect I'm about to learn a ton of new information about either Play and/or UTF-8 or HTML or some part of the chain where this is going off the rails.
My question then is this: Is there an idiomatic Play example of how to handle UTF-8 end to end through Anorm and into Java Mail?
(I think I kinda expected it to be "built-in" but then I expected a LOT more to be baked into the core product as well...)
I want/need both a TEXT and and HTML path for the email portion. (I can write BOTH and they work fine -- the problem is moving alternate characters though the channels as indicated above).
I'm currently seeing if this might be an answer:
https://objectpartners.com/2013/04/24/html-encoding-utf-8-characters/
However presently hitting this roadblock...
How to turn off specific Implicit's in Scala that prevent code from compiling due to overloaded methods?
This appears to be a hopeful candidate -- I am researching it now end to end.
import org.apache.commons.lang3._
def htmlEncode(input: String) = htmlEncode_sb(input).toString
def htmlEncode_sb(input: String, stringBuilder: StringBuilder = new StringBuilder()) = {
stringBuilder.synchronized {
for ((c, i) <- input.zipWithIndex) {
if (CharUtils.isAscii(c)) {
// Encode common HTML equivalent characters
stringBuilder.append(StringEscapeUtils.escapeHtml4(c.toString()))
} else {
// Why isn't this done in escapeHtml4()?
stringBuilder.append(s"""&#${Character.codePointAt(input, i)};""")
}
}
stringBuilder
}
}
In order to get it to work inside Play you'll need this in your build.sbt file
"org.apache.commons" % "commons-lang3" % "3.4",
This blog post lead me to write that code: https://objectpartners.com/2013/04/24/html-encoding-utf-8-characters/
Update: Confirmed that it does work end to end.
Web Page Input as TextArea inside a Form saved to MySQL database escaped by Anorm, reread from database and displayed inside a TextArea on a web page with extended characters (visually) appearing precisely as input.
You'll need to call #Html(htmlContentString) inside the Twirl template to re-render this as the original HTML but the browser (Safari 8.0.7) displayed exactly what I gave it after a round trip to and from the database.
One caveat -- it creates machine readable HTML not human readable HTML. It would be nice if it didn't encode angle brackets and such so it looks more like HTML that we expect. I'm sure a pattern match block will be added next to exclude just that :)

Append string to a Flash AS3 shared object: For science

So I have a little flash app I made for an experiment where users interact with the app in a lab, and the lab logs the interactions.
The app currently traces a timestamp and a string when the user interacts, it's a useful little data log in the console:
trace(Object(root).my_date + ": User selected the cupcake.");
But I need to move away from using traces that show up in the debug console, because it won't work outside of the developer environment of Flash CS6.
I want to make a log, instead, in a SO ("Shared Object", the little locally saved Flash cookies.) Ya' know, one of these deals:
submit.addEventListener("mouseDown", sendData)
function sendData(evt:Event){
{
so = SharedObject.getLocal("experimentalflashcookieWOWCOOL")
so.data.Title = Title.text
so.data.Comments = Comments.text
so.data.Image = Image.text
so.flush()
}
I don't want to create any kind of architecture or server interaction, just append my timestamps and strings to an SO. Screw complexity! I intend to use all 100kb of the SO allocation with pride!
But I have absolutely no clue how to append data to the shared object. (Cough)
Any ideas how I could create a log file out of a shared object? I'll be logging about 200 lines per so it'd be awkward to generate new variable names for each line then save the variable after 4 hours of use. Appending to a single variable would be awesome.
You could just replace your so.data.Title line with this:
so.data.Title = (so.data.Title is String) ? so.data.Title + Title.text : Title.text; //check whether so.data.Title is a String, if it is append to it, if not, overwrite it/set it
Please consider not using capitalized first letter for instance names (as in Title). In Actionscript (and most C based languages) instance names / variables are usually written with lowercase first letter.

To emoji or not to emoji?

I finally found a way to overcome issue with emojis in user inputs in my Rails 4 app. It was causing 'incorrect string value' errors.
The solution was to set utf8mb4 (using MySQL) not only in DB encoding*collation but also in database.yml.
So now it works. But the problem is that rendering is not consistent across the browsers as always :) And it feels like I have no control over user inputs anymore.
Is there an easy way to strip 4-byte characters, or possible just emojis from the user's input before saving the records and storing them in DB?
Thanks!
You can override the attribute setters in your models to do whatever you want to the value before it's stored. Then, borrowing the regex from this stack overflow post (looks Greek to me!), try:
# Do this for each attribute in your model:
def my_attr=(value)
value = value.to_s.gsub(/\360\237/, '')
super(value.presence)
end
I found one more solution for Emoji here: https://dev.firmafon.dk/blog/quick-no-hack-emoji-support-with-mysql-rails/
class Rating < ActiveRecord::Base
serialize :comment
end

How do you access the value of a JTextField in JRuby?

I want to use the value of the text field to validate the username and password for my GUI. I have tried this code:
If user.Text = "abc" and passwrd.Text = "abc" then
You access it the exact same as you would in Java:
my_text_field.getText
JRuby has some nice syntactic sugar to make interoperating with Java feel more Ruby-like, which you can also use:
# these are equivalent
my_text_field.get_text
my_text_field.text

Octave plots: set box off by default, override factory defaults

I seek to override a default setting in Octave concerning plots. For instance, I always set box off; when plotting, so I would like to set the box off by default. Perhaps factoryaxesbox is the involved setting (are those factory settings documented anywhere?).
When I see a setting returned by get(0, "factory"), how can I assign a new default to override this?
I have been through this section of the Octave manual, section 15.3.5: Managing Default Properties, but it says little and I find it rather confusing. Object type, root object, child object, … Huh?
Figured it out after some amount of trial and error.
The name of available properties for plots are those returned by get(0, "factory"), without the factory prefix. In order to override any of these, you must prefix the property name with default, in the format set(0, "defaultNameOfProperty", "newsetting").
To set box off by default for all plots:
set(0, "defaultaxesbox", "off")
Before doing this, if you check for the existence of this property defaultaxesbox, using get(0, "default"), you will find nothing, making you wonder if you can set a setting which does not seem to exist. After the assignment has been made with set(), it will show up in get(0, "default").
If the first argument of set() was gca() or some other number, then replace zero with that in the above get().