I want to implement a clickable link in StyledTextCtrl, seems hotspots
is the way to go (when mouse hove on hotspot, cursor changed to ‘hand’,
can fire a click event).
My code (below) only works when a lexer is not set!
Is there a way to dynamically set certain text to be hotspots?
def initialize
set_lexer(STC_LEX_RUBY) # if set, the hotspot style is lost
I want to implement a clickable link in StyledTextCtrl, seems hotspots
is the way to go (when mouse hove on hotspot, cursor changed to ‘hand’,
can fire a click event).
My code (below) only works when a lexer is not set!
Is there a way to dynamically set certain text to be hotspots?
To be honest, I’m not sure. I would look for help via Scintilla on this
as you probably guessed, StyledTextCtrl is a pretty thin layer of this
editing component.
This page here would suggest that if a lexer is present, it has control
of setting hotspots:
This may mean it’s not possible, or not possible without writing your
own lexer. Whether this is possible in Ruby with StyledTextCtrl I don’t
know - I haven’t explored the (large) STC API enough to know. But it
would be interesting…
In wxRuby the form of event handling for custom lexing will look
something like
evt_stc_styleneeded(self) do | evt |
start_pos = end_styled
line_num = line_from_position( start_pos )
start_pos = position_from_line( line_num )
# start styling at position
start_styling(start_pos, 31)
# do whatever styling is needed to text chunks
set_styling(evt.position - start_pos, 2)
end
good luck!
a
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.