Determining Event KeyCode on Mobile Browser (Chrome, Android, Firefox)

Recently, I run into a very common issue with regards to determining the Event KeyCode when entering text into a textarea on a mobile device. This had me scratching my head for a good couple of hours, but eventually I managed to get a solution that works perfectly well on desktop and mobile for the same piece of code. Continue reading “Determining Event KeyCode on Mobile Browser (Chrome, Android, Firefox)”

Advertisements

Raphael.js: Get Value Of A Text Node

When using the Raphael.js library for SVG manipulation, setting the text of a text element is as easy as

var paper = Raphael(10, 50, 320, 200);
var textEl = paper.text("My Text", 0, 0); // create a new element

// and later if we want to update the text
textEl.attr('text', 'My New Text');

However, getting the current text in this node is not as straight forward. The library dictates you should do something similar to var currentText = textEl.attr('text');, but logging that to the console outputs an Object and not a String. I’ve searched the net for months for the answer to this, and the solution I finally came up with today, after inspecting the DOM and seeing the elements being returned, is as simple as

var currentText = textEl[0].attr['text'];

The reason it needs to be this way is because the library treats the text node as a “Set” of two text elements instead of a simple HTML Element with inner text. I hope I’ve helped someone today. Happy JS Development, y’all.

Something I Would Love To Do In Java

Java is a pretty cool language, and I think it is good for teaching the basics about programming. The following is just something I look forward to doing in future versions of Java if Object literals are added.

Here is how u define a rectangle in JavaFX using Java at the moment

Rectangle rect = new Rectangle();
   rect.setFill(Color.RED);
   rect.setWidth(200);
   rect.setHeight(100);
   rect.setX(20.0f);
   rect.setY(20.0f);

Here is how I would love to be able to define it,

Rectangle rect = new Rectangle({
   fill: Color.RED,
   width: 200,
   height: 100,
   x: 20.0f,
   y: 20.0f
});

I believe I have been spoiled by my usage of Javascript, and I could use other VM languages, but I think this is just fun to look at. This inherently has issues, because there would need to be to be a lot of Type Casting in order to get the variables out or to set them accordingly, because the Map passed as the argument would need to be defined as HashMap<String, Object> to ensure any value could be passed. The implementation of the Rectangle class would then need to internally map these properties to the right variables somehow.

With Collection Literals in Java 8 onwards, this all will be possible, but the other issue would be if the various UI Classes like Rectangle would be refactored to make the above code possible. I highly doubt it personally, but nothing is impossible.

I will certainly play around with this a bit later. Feel free to share your own ideas in the comments below.

My First Programming Language Was Javascript

Many people start off programming learning all sorts of things. Several years ago, the most common languages to start learning programming in were Basic and Visual Basic, then the advent of C, C++ and Java came, and they were the standard first languages to learn. However, for me, being mostly a self taught programmer, my first actual programming language was Javascript. That is if you can call it a programming language. I was just 14 then.

Continue reading “My First Programming Language Was Javascript”

The War On IE 6

Recently Google openly declared that it would be dropping support for IE6 for most of its applications such as Google Docs and GMail. That is a bold step I side with. In the recent times, for all the web development work I do, I do not even bother to test in IE6 because I do not care for the user experience in that browser. Most of my work has been to develop content management related products for my websites, and I know most of my users are developers who are up to date with all the recent browser trends so they are well equipped for my products.

However, recently I got bitten in the ass by this lack of support for IE6 when a client viewed a website I created in it, and the result was terrible. I viewed the site myself and I was shocked by the horrors I came face to face with. See below for expected results and what IE6 renders; Continue reading “The War On IE 6”

My Wish List For Dreamweaver CS5 – Reviewed

In my last post, I briefly made some suggestions as to some of the features I would like to see incorporated into Dreamweaver CS5 in order to make it an even more killer application than it is right now. I have now managed to throughly use Dreamweaver CS4 and would like to post my reviewed wish list for CS5.

PHP Support.

Dreamweaver CS4’s PHP Support has always been good, but far below expectations. Currently, Dreamweaver has some good code generation for PHP when it come to developing applications. It generates appreciable code for SQL SELECT, INSERT, UPDATE and DELETE with appreciable PHP code for accessing the recordset generated. It supports dynamically generated tables and lists using the generated recordset which makes it very useful for building simple applications. Continue reading “My Wish List For Dreamweaver CS5 – Reviewed”

My Wish List For Dreamweaver CS5

So far I have read reviews and heard of some of the new features of Dreamweaver CS4 and I must say they are cool, but they still do not meet the expectations I had for it. Personally I have used earlier versions of Dreamweaver and demos of current versions and one thing I believe the software lacks (which others have done so well the incorporate) is a good code editor.

The current Dreamweaver code editor has remained much the same since version 8 and at that point it was lacking in “intellisense” (hope that is the right spelling). The Dreamweaver code completion features are not as adequate as they ought to be. Currently, code completion for HTML and CSS is fair enough, however, Javascript, PHP and other server side languages is still lacking massively. They thing I hate the most is that when I’ve coding a piece of Javascript in a PHP document, and I hit CTRL + SPACE to get the code completion menu, I’m giving the menu for PHP and nothing for Javascript. I guess I could say then that, it is more of a lack of code completion for Javascript than much else that is missing in Dreamweaver.

I’m yet to test out the new features in CS4 but I guessing much hasn’t changed since I have not seen any reviews about changes in the code editor. There are a lot cool features for CS4 like improved Live Editing and extra Spry framework features. I hoping for the best in CS5, because I also use Netbean (6.1 currently) and I must say coding in that environment is more than decent. All the best to Adobe, and let’s see if things change in that direction.