librelist archives

« back to archive

Re: appending stacks - element selection issue

Re: appending stacks - element selection issue

From:
Sebastjan Hribar
Date:
2015-04-16 @ 16:40
My mail was apparently bounced, so here it is again...

Dne 14. 04. 2015 ob 19:49 je Sebastjan Hribar zapisal(a):
> Hi,
>
> in my computer aided translation tool I have a method for splitting a 
> text blok into sentences and for each sentence a stack is appended to 
> another stack. The appended stack contains edit boxes and a button 
> which triggers the translation pair to be saved to a respective 
> translation memory.
>
> My problem is, that no matter which button I press (no matter in which 
> of the appended stacks), the translation pair is always taken from the 
> last appended stack.
>
> I've tried the "array approach" which was suggested by ashbb for one 
> of my other apps and wordked 
> 
(http://librelist.com/browser//shoes/2013/3/13/dragons-direwolves-issues/#03edd291bfbe77a5cd8c4529fbbc583f)

> but it doesn't here.
>
> As I said, in the new_segment method below, the arguments are always 
> taken from the last appended stack.
>
> Can this be fixed?
>
> <<<method in helpers file>>>
> #Split a text block
>   def text_block_split(text, translation_memory)
>     sentences = text.split(".")
>     c = []
>     sentences.each_with_index do |sentence, index|
>       @translation_stack.append {
>         c[index] = flow margin: [75,0,0,0] do
>           @source_sentence = edit_box width: 300
>           @source_sentence.text = sentence
>           @target_sentence = edit_box width: 300
>           button "Add translation" do
>             new_segment(@source_sentence.text, @target_sentence.text, 
> translation_memory)
>           end
>         end
>       }
>     end
>   end
> <<<method in helpers file>>>
>
> <<<view>>>
>     def clipboard_translation_multiple
>       background lightcoral
>       home
>       @text_block_input = edit_box width: 600, height: 100
>       button "Prepare text" do
>         text_block_split(@text_block_input.text, $translation_memory)
>       end
>       @translation_stack = stack do
>       end
>     end
> <<<view>>>
>
> thanks,
> regards,
> seba