Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, February 21, 2010

Bug 540112

I have been working on my bug for quite some time now, which seems to be, for the majority, trying different things to make it work and reviewing my JavaScript...I am a little out of practice with JavaScript at the moment as I have not done it since second semester in INT222. I missed it, it's a good language...unfortunately nothing I do to make this cursor blink is working...I will need to use an SC.Timer to make it blink but I think I'd have to pass parameters into the timer, as the function that draws the cursor has two parameters: rect, and context. I remember having to make or call a fire method, or something like it, to fire off the function in question but that would also need parameters and you can't send in parameters with the timer's action property.
What I have now is...

The cursor drawing function...

_drawInsertionPoint: function(rect, context) {
var range = this._selectedRange;
var characterRect = this.get('layoutManager').
characterRectForPosition(range.start);

context.save();

context.strokeStyle = this.get('theme').cursorStyle;

context.beginPath();
context.moveTo(characterRect.x + 0.5, characterRect.y);
context.lineTo(characterRect.x + 0.5,
characterRect.y + characterRect.height);
context.closePath();
context.stroke();

context.restore();
},

The timer function...

_cursorBlinkTimer: function() {
this._cursorBlinkTimer = SC.Timer.schedule({
target: this,
action: '_fireDrawInsertionPoint', /*Had _drawInsertionPoint but can't pass in parameters with this */
interval: 250,
repeats: true
});
},

I thought it needed some sort of other method to send in the parameters but that would need to be called using parameters in the action: property above so that couldn't work...

_fireDrawInsertionPoint: function(rect, context) {
if(this.get('isFirstResponder')) {
drawInsertionPoint(rect, context);
}
},

The place that calls the cursor drawing function...

_drawSelection: function(rect, context) {
if (this._rangeIsInsertionPoint(this._selectedRange)) {
this._drawInsertionPoint(rect, context); //Thought this had to be this._cursorBlinkTimer()
} else {
this._drawSelectionHighlight(rect, context);
}
},



So I'm in a bit of a bind and have been looking around for quite some time but am not coming up with much to go on. I even asked Yahoo Answers lol and they said the way it was coded would be tricky. A fellow on irc told me that I should look into property-observing functions of SC...for something like an isCursorVisible property...I've been looking but haven't been coming up with much and that is much different than what I have done so far but anything is acceptable as long as it works and is it good taste. Hmm. Tricky.

Monday, February 15, 2010

Built Bespin Locally

In order to have full access to the files and to be able to test the environment properly, I have just built Bespin on my Windows laptop. I had to use cygwin and treat my computer like a Unix OS and I must say, it does a good job. The download/clone went flawlessly and I am now able to work on the bugs more effectively. I was unsure where to begin looking for the 'scrollbar cursor does not change' code in the repository but looking back at my bug page, a fellow by the name of Julian has implemented some code that could be useful for my bug. It seems that the code he edited was in this file:

plugins/supported/Editor/views/canvas.js


and is called from this file:

plugins/supported/Editor/views/text.js


This seems like a good place to start looking. Thank you Julian, wherever you are...