Sha256: d7f3336368fe77272977190d9eec8e8287bb988086263898c2f966aa348afae7

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'Context/Context'
require 'Context/Bridge'
require 'Context/View'

module JLDrill

	class PromptContext < Context::Context
		
	    attr_reader :cancel, :yes, :no, :response, :title, :message
	    		
		def initialize(viewBridge)
			super(viewBridge)
	        @cancel = "cancel"
	        @yes = "yes"
	        @no = "no"
			@response = @cancel
            @title = "Prompt"
            @message = "Please replace this with a question for the user."
		end
	
        class PromptView < Context::View
            attr_reader  :response, :title, :message

            def initialize(context, title, message)
                super(context)
                @title = title
                @message = message
                @response = @context.cancel
            end

            # Destroys the prompt window
            def destroy
                # Please override in the concrete class
            end

            # Display the dialog and get the input from the user
            def run
                # Please override in the concrete class
            end
        end

        # The concrete class should override this method    
		def createViews
            # Please set the title and message member variables
            # and call super() in the concrete class
    		@mainView = @viewBridge.PromptView.new(self, @title, @message)
        end

        def destroyViews
            @mainView.destroy if !@mainView.nil?
            @mainView = nil
        end		    
		
		def enter(parent)
		    super(parent)
    		@response = @mainView.run
    		self.exit
    		return @response
		end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.5.1.7 lib/jldrill/contexts/PromptContext.rb